Browsed by
Tag: Complete Notes on Database Management System

What are indexes? What are B-Trees

What are indexes? What are B-Trees

Index makes your search faster. So defining indexes to your database will make your search faster.Most of the indexing fundamentals use “B-Tree” or “Balanced-Tree” principle. It’s not a principle that is something is created by SQL Server or ORACLE but is a mathematical derived fundamental.In order that “B-tree” fundamental work properly both of the sides should be balanced.

What’s difference between DBMS and RDBMS

What’s difference between DBMS and RDBMS

DBMS provides a systematic and organized way of storing, managing and retrieving from collection of logically related information. RDBMS also provides what DBMS provides but above that it provides relationship integrity. So in short we can say: RDBMS = DBMS + REFERENTIAL INTEGRITY These relations are defined by using “Foreign Keys” in any RDBMS.Many DBMS companies claimed there DBMS product was a RDBMS compliant, but according to industry rules and regulations if the DBMS fulfills the twelve CODD rules it’s…

Read More Read More

What’s the difference between DELETE and TRUNCATE

What’s the difference between DELETE and TRUNCATE

Following are difference between them: DELETE TABLE syntax logs the deletes thus making the delete operations low. TRUNCATE table does not log any information but it logs information about deallocation of data page of the table. So TRUNCATE table is faster as compared to delete table. DELETE table can have criteria while TRUNCATE can not. TRUNCATE table can not have triggers.

I have a table which has lot of inserts, is it a good database designto create indexes on that table

I have a table which has lot of inserts, is it a good database designto create indexes on that table

Insert’s are slower on tables which have indexes, justify it?or Why do page splitting happen? All indexing fundamentals in database use “B-tree” fundamental. Now whenever there is new data inserted or deleted the tree tries to become unbalance. Creates a new page to balance the tree.Shuffle and move the data to pages. So if your table is having heavy inserts that means it’s transactional, then you can visualize the amount of splits it will be doing. This will not only…

Read More Read More

What are E-R diagrams

What are E-R diagrams

E-R diagram also termed as Entity-Relationship diagram shows relationship between various tables in the database. The correct answer would be: E-R diagrams, short for Entity-Relationship diagrams, are visual representations used in database design to depict the logical structure of a database. They illustrate the entities within the system and the relationships between them. These diagrams typically consist of entities (which represent real-world objects or concepts), attributes (characteristics of entities), and relationships (associations between entities). E-R diagrams serve as blueprints for…

Read More Read More

What’s the difference between “UNION” and “UNION ALL

What’s the difference between “UNION” and “UNION ALL

UNION SQL syntax is used to select information from two tables. But it selects only distinct records from both the table. , while UNION ALL selects all records from both the tables. The main difference between “UNION” and “UNION ALL” in database management systems (DBMS) lies in how they handle duplicate rows. UNION: This operator combines the result sets of two or more SELECT statements, removing any duplicate rows from the final result set. It effectively performs a set union…

Read More Read More

How will you represent a hierarchical structure shown below in a relational database? or How will you store a tree data structure into DB tables?

How will you represent a hierarchical structure shown below in a relational database? or How will you store a tree data structure into DB tables?

The hierarchical  data is an example of the composite design pattern. The entity relationship diagrams (aka ERdiagram) are used to represent logical and physical relationships between the database tables. The diagram below shows how the table can be designed to store tree data by maintaining the adjacency information via superior_emp_id.   As you can see the “superior_emp_id” is a foreign key that points to the emp_id in the same table. So, Peter has null as he has no superiors. John and Amanda points to  Peter who is their…

Read More Read More

What is normalization? What are different types of normalization

What is normalization? What are different types of normalization

There is set of rules that have been established to aid in the design of tables that are meant to be connected through relationships. This set of rules is known as Normalization. Benefits of normalizing your database include: Avoiding repetitive entries Reducing required storage space Preventing the need to restructure existing tables to accommodate new data. Increased speed and flexibility of queries, sorts, and summaries. Following are the three normal forms: First Normal Form For a table to be in…

Read More Read More

What are cursors and what are the situations you will use them

What are cursors and what are the situations you will use them

SQL statements are good for set at a time operation. So it is good at handling set of data. But there are scenarios where we want to update row depending on certain criteria. we will loop through all rows and update data accordingly. There’s where cursors come in to picture. Cursors in database management systems (DBMS) are programming constructs used to retrieve and manipulate data from a result set, typically within a procedural language like SQL or PL/SQL. They enable…

Read More Read More

How will you find out the superior for an employee whose emp_id is 3

How will you find out the superior for an employee whose emp_id is 3

You can use a self-join to find the manager of an employee whose emp_id is 3 Select e.emp_id,e.emp_name, title Fromemployee e, employee s where e.superior_emp_id = s.employee_idand e.emp_id = 3 This should return: 1, Peter, CIO To find the superior for an employee with emp_id 3 in a database management system (DBMS), you would typically execute a SQL query that retrieves the superior’s information based on the hierarchical relationship stored in the database. Assuming there’s a table named “employees” with columns like…

Read More Read More