Top 24 SQL Interview Questions & Answers

date
May 8, 2024
slug
sql-interview-questions
status
Published
tags
SQL
DBMS
Interview
summary
Explain to DBMS, RDBMS, SQL And More
type
Post
Hello Everyone, first of fall, thanks for visiting this website.Hello Everyone, first of fall, thanks for visiting this website.
Hello Everyone, first of fall, thanks for visiting this website.
1.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 file systems.
2.What is RDBMS?
RDBMS stands for Relational Database Management System. RDBMS store the data into the collection of tables, which is related by common fields between the columns of the table. It also provides relational operators to manipulate the data stored into the tables. Example: SQL Server.
3.What is SQL?
SQL stands for Structured Query Language, and it is used to communicate with the Database. This a standard language used to perform tasks such as retrieval, updation, insertion and deletion of data from a database. Standard SQL Commands are Select.
4.What is a Database?
Database is nothing but an organized form of data for easy access, storing, retrieval and managing of data. This is also known as structured form of data which can be accessed in many ways. Example: School Management Database, Bank Management Database.
5.What are tables and Fields?
A table isa set of data that are organized in a model with Columns and Rows. Columns 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, Date of Birth. Data: 201456, David, 11/15/1960.
6.What is a primary key?
A primary key is a combination of fields 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 be NULL.
7.What is a unique key?
A Unique key constraint uniquely identified each record in the database. This provides uniqueness for the column or set of columns. 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.
8.What is a 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 of another table.
9.What is a join?
This is a keyword used to query data from more tables based on the relationship between the fields of the tables. Keys play a major role when JOINS are used.
 
10.What is normalization?
Normalization is the process of minimizing redundancy and dependency by organizing fields and table of a database. The main aim of Normalization is to add, delete or modify field that can be made in a single table.
11.What are all the different normalizations?
The normal forms can be divided into forms, and they are explained Database Normalization can be easily understood with the help of a case study. below
  • First Normal Form (1 NF): This should remove all the duplicate columns from the table. Creation of tables for the related data and identification of unique columns.
  • Second Normal Form (2NF): Meeting all requirements of the first normal form. Placing the subsets of data in separate tables and Creation of relationships between the tables using primary keys.
  • Third Normal Form (3NF): This should meet all requirements of 2NE. Removing the columns 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 in 4th Normal Form.
  • Fifth Normal Form (5NF): A table is in 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
12.What are local and global variables and their differences?
Local variables are the variables which can be used or exist inside the function. They are not known to the other functions and those variables cannot be referred or used. Variables can be created whenever that function is called. Global variables are the variables which can be used or exist throughout the program. Same variable declared in global cannot be used in functions. Global variables cannot be created whenever that function is called.
13.What is a constraint?
Constraint can be used to specify the limit on the data type of table. Constraint can be specified while creating or altering the table statement. Sample of constraint are.
NOT NULL.
CHECK.
DEFAULT.
UNIQUE.
PRIMARY KEY.
FOREIGN KEY.
 
14.What is data Integrity?
Data Integrity defines the accuracy and consistency of data stored ina database. It can alsso define integrity constraints to enforce business rules on the data when it is entered into the application or database.
15.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.
 
16.What is Denormalization?
DeNormalization isa technique used to access the data from higher to lower normal forms of database. It is also process of introducing redundancy into a table by incorporating data from the related tables.
17.What is a View?
A view is a virtual table which consists 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.
18.What is an Index?
An index performance tuning method of allowing faster retrieval of records from the table. An index creates an entry for each value and it will be faster to retrieve data.
19.What is a relationship and what are they?
Database Relationship is defined as the connection between the tables 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.
 
20.What is a query?
A DB query 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.
21.What is the difference between DELETE and TRUNCATE commands?
DELETE Command is used to remove rows 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.
 
22.What is the difference between Cluster and Non-Cluster Index?
Clustered index used for easy retrieval of data from the database by altering the way that the records are stored. Database sorts out rows by the column which is set to be clustered index. A nonclustered index does not alter the way it was stored but creates a complete separate object within the table. It point back to the original table rows after searching.
 
23.What is user defined functions?
User defined functions are the functions written to use that logic whenever required. It is not necessary to write the same logic several times. Instead, functions can be called or executed whenever needed.
24.What are all types ofuser defined functions?
Three types of user defined functions are.
  • Scalar Functions.
  • Inline Table valued functions.
  • Multi statement valued functions.
Scalar returns unit, variant defined the return clause. Other two types return tables as a return.
 
 
இந்த உரையைப் பற்றிய எந்த கேள்விகள் உள்ளன, என்னுடைய தொடர்புக்கு தொடரவும்.