Top 21 SQL Interview Questions & Answers


Top 21 SQL Interview Questions & Answers

What is DBMS?

A Database Management System(DBMS) is a program that controls creation, maintenance and use of a database. DBMS can be termed as file manager that manages data in a database rather than saving it in the system.

What is RDMS?

RDMS stands for Relational Database Management System. RDMS store the data into the collection of tablets, which is related by common field between the column of the table. It also provide relational operators to manipulate the data stored into the tablets.

Ex: SQL Server

What is SQL?

SQL stands for structured Query Language. and it used to communicate with the Database. This is a structured language used to perform tasks Such as retrieval, updation , Insertion and detection of data from database.

What is Database?

Database is nothing but an organized from of data for easy access, storing, retrieval and managing data. This is also known as structural from data which can accessed in many ways.

Example: School Management Database, Bank Management Database.

What is Tables and fields?

A table is s set data that are organized in a model with columns and rows. Column can be categorized as vertical and Rows are horizontal. A table has specified number of column called fields but can have any number of rows which is called record.

Example: 

Table: Employee 

Field: Emp id , Emp name , Emp DOB

What is a primary key?

A primary key is a collection of field which uniquely specify a row. This is a special kind of unique key , and it has implicit NOT NULL constraint. It means, primary key values cannot the NULL.

What is Unique?

A Unique key  constraint uniquely identified each record in the database. This provides uniqueness for the column or set of column.

A Primary key Constraint has automatic unique constraint defined on it. But not, in the case of unique key.

There  can be many unique constraint defined per table, but only one primary key constraint defined per table.

What is foreign key?

A foreign key is one table which can be related to the primary key of another table. Relationship needs to be created between two tables by referencing foreign key with the primary key to another table.

What is join?

This is a keyword used to query data from more tables based on the relationship between the fields of the tables. Key play a major role when JOINs are used.

What is Normalization?

Normalization is the process the minimizing redundancy and dependency by organizing fields and table of a database. The main aim Normalization is to add, delete or modify field that can be made in a single table.

What are all the different normalization ?

Database Normalization can be easily understood with the help of case study.

The normal forms can be divided into 6 forms and they are explained below:

  • First Normal Form (1NF): This should remove all the duplicate columns from the table. Creation of tables for the related data identification of unique column.
  • Second Normal From (2NF) : Meeting all requirement of the first normal from. Placing the subset of data in separate tables and creation of relationships between the tables using primary key constraint.
  • Third Normal Form (3NF) : This should meet all requirement of 2NF. Removing the column which are not dependent on primary key constraints.
  • Fourth Normal Form (4NF) : If no database table instance contains two or more, independent and multivalued data describing the relevant entity. then it is 4th Normal form.
  • Fifth Normal Form (5NF) : A table is 5th Normal Form only if it is in 4NF and it cannot be decomposed into any number of smaller tables without loss of data. 
  • Sixth Normal Form (6NF) : 6th Normal Form is not standardized , yet however, it is being discussed by database experts for some time. Hopefully we would have clear & standardized definition for the 6NF in the near future.

What is Denormalization ?

Denormalization is a technique used to access data from higher to slower normal forms of database. It is also process of introducing redundancy into a table by incorporating  data from the related tables.

What is view?

A view is a Virtual table which consist of a subset of data contained in a table. Views are not virtually present. and it takes less space to store. View can have data of one or more tables combined. and it is depending on the relationship.

What is Index?

An Index is performance tuning method of allowing faster retrieval of records from the table. An index creates an entry for each value and it will faster to retrieve data.

What is relationship and what are they ?

Database Relationship is defined as the connection between the tablets in a database. There are various data basing relationships, and they are as follows:

  • One to One Relationship
  • One to Many Relationship
  • Many to One Relationship
  • Self-Referencing Relationship

What is Query?

A database is a code written in order to get the information back from the database. Query can be designed in such a way that it matched with our expectation of the result set. Simply , a question to the database.

What is the different between DELETE and TRUNCATE commands?

  • DELETE command is used to remove row from the table. and WHERE  clause can be used for conditional set of parameters. Commit and Rollback can be performed after delete statement.
  • TRUNCATE removes all rows from the table. Truncate operation cannot be rolled back.

What are local and global variable and their difference?

  • Local variable are the variables which can be used or exist inside the function. They are not known to the other function and those variables cannot be referred or used. variables can be created whenever that function is called.
  • Global variables are the variable which can be used to exist throughout the program. Same variable declared in global cannot be used in functions. Global variables cannot be  created whenever that function is called.

What is Constraint?

Constraint can be used to specify that limit on the data type or table. Constraint can be specified while creating or altering the table statement.

Sample Constraint are:

  • NOT NULL
  • CHECK
  • DEFAULT
  • UNIQUE KEY
  • PRIMARY KEY 
  • FOREIGN KEY

What is data Integrity?

Data integrity defines that accuracy and consistency of data stored in a database. It can be also define integrity constraints to enforce business rules on the data when it is entered into the application or database.

What is Datawarehouse ?

Datawarehouse is a central repository of data from multiple sources of information. Those data are consolidated , transformed and made available for the mining and online processing warehouse data have a subset of data called Data Marts.


Comments

Popular Posts