Browsed by
Tag: Database Management System Questions Asked in Interview

What is de-normalization

What is de-normalization

Denormalization is the process of putting one fact in numerous places (its vice-versa of normalization).Only one valid reason exists for denormalizing a relational design – to enhance performance.The sacrifice to performance is that you increase redundancy in database. Denormalization in database management refers to the process of intentionally introducing redundancy into a database design, usually for performance reasons. This involves adding redundant data to one or more tables within the database to help optimize read performance, simplify queries, or reduce…

Read More Read More

What is “Group by” clause

What is “Group by” clause

Group by” clause group similar data so that aggregate values can be derived. The “Group by” clause in a database management system (DBMS) is used to group rows that have the same values into summary rows or groups based on one or more columns. It is commonly used with aggregate functions like COUNT, SUM, AVG, MAX, or MIN to perform calculations on each group of rows. Essentially, it helps in categorizing data and applying aggregate functions to each category.

Is there any other way to to store tree structure in a relational database

Is there any other way to to store tree structure in a relational database

Yes, it can be done using the “modified preorder tree traversal” as described below.As shown in the previous diagram above, each node is marked with a left and right numbers using a modified preorder traversalas shown above. This can be represented in a database table as shown below. Yes, there are alternative methods for storing tree structures in a relational database. One common approach is called the “adjacency list model,” where each node in the tree has a reference to its parent node. Another approach is the…

Read More Read More

Can you explain Fourth Normal Form and Fifth Normal Form

Can you explain Fourth Normal Form and Fifth Normal Form

In fourth normal form it should not contain two or more independent multi-v about an entity and it should satisfy “Third Normal form”. Fifth normal form deals with reconstructing information from smaller pieces of information. These smaller pieces of information can be maintained with less redundancy. Sure, I’d be happy to explain Fourth Normal Form (4NF) and Fifth Normal Form (5NF). Fourth Normal Form (4NF): 4NF is a level of database normalization that builds upon the concepts of Third Normal…

Read More Read More

What is a Sub-Query

What is a Sub-Query

A query nested inside a SELECT statement is known as a subquery and is an alternative to complex join statements. A subquery combines data from multiple tables and returns results that are inserted into the WHERE condition of the main query. A subquery is always enclosed within parentheses and returns a column. A subquery can also be referred to as an inner query and the main query as an outer query. JOIN gives better performance than a subquery when you…

Read More Read More

Write SQL query as mentioned below: you can see the numbers indicate the relationship between each node.

Write SQL query as mentioned below: you can see the numbers indicate the relationship between each node.

As you can see the numbers indicate the relationship between each node. All left values greater than 6 and right values less than 11 are descendants of  6-11 (i.e Id: 3 Amanda). Now If you want to extract out the 2-6 sub-tree for Amanda. What SQL query you will write? SELECT * FROM employee WHERE left_val BETWEEN 6 and 11 ORDER BY left_val ASC; To extract the sub-tree rooted at the node with ID 2-6 for Amanda, you would typically…

Read More Read More

Have you heard about sixth normal form

Have you heard about sixth normal form

If we want relational system in conjunction with time we use sixth normal form. At this moment SQL Server does not supports it directly. Yes, I’m familiar with the concept of sixth normal form (6NF) in database management systems (DBMS). It’s an advanced level of normalization in which every non-trivial join dependency in the table is a logical consequence of the candidate keys. This form is rarely used in practical database design due to its complexity and limited applicability. It’s…

Read More Read More

What are Aggregate and Scalar Functions

What are Aggregate and Scalar Functions

Aggregate and Scalar functions are in built function for counting and calculations. Aggregate functions operate against a group of values but returns only one value. AVG(column) :- Returns the average value of a column COUNT(column) :- Returns the number of rows (without a NULL value) of a column COUNT(*) :- Returns the number of selected rows MAX(column) :- Returns the highest value of a column MIN(column) :- Returns the lowest value of a column Scalar functions operate against a single…

Read More Read More

Which will return Amanda, Ralph, and Jeanne. If you want to get ancestors to a given node say 7-8 Ralph. What SQL query you will write?

Which will return Amanda, Ralph, and Jeanne. If you want to get ancestors to a given node say 7-8 Ralph. What SQL query you will write?

SELECT * FROM employee WHERE left_val < 7 and right_val > 8 WHERE ORDER BY left_val ASC; To retrieve ancestors of a given node in a hierarchical structure stored in a database using SQL, you typically use recursive queries, which are supported by some relational database management systems (RDBMS) like PostgreSQL, SQL Server, and Oracle. Assuming you’re using a database system that supports recursive queries, here’s an example SQL query: sql WITH RECURSIVE Ancestors AS ( SELECT id, parent_id, name…

Read More Read More

What are DML and DDL statements

What are DML and DDL statements

DML stands for Data Manipulation Statements. They update data values in table. Below are the most important DDL statements:- SELECT – gets data from a database table UPDATE – updates data in a table DELETE – deletes data from a database table INSERT INTO – inserts new data into a database table DDL stands for Data definition Language. They change structure of the database objects like table, index etc. Most important DDL statements are as shown below:- CREATE TABLE –…

Read More Read More