SQL Interview Questions Set -1

Q1. What is SQL?

SQL stands for the Structured Query Language. According to ANSI (American National Standards Institute), it is the standard language for relational database management systems. It is a database language used for database creation, deletion, fetching and modifying rows, etc. sometimes, it is pronounced as 'sequel.


Q2. What are the usages of SQL?

1) To retrieve data from a database

2) To inserts records in a database

3) To create views in a database

4) To updates records in a database

5) To delete records from a database

6) To create new databases

7) To create new tables in a database.


Q3. Does SQL support programming language features?

SQL refers to the Standard Query Language. Therefore, it is true that SQL is a language but does not actually support the programming language. It is a common language that doesn't have a loop, conditional statements, and logical operations. It cannot be used for anything other than data manipulation. It is a command language to perform database operations.


Q4. What are the components of SQL?

1) DDL: It stands for Data definition language. It defines the data structure that consists of commands like CREATE, ALTER, DROP, etc.

2) DML: It stands for Data manipulation language. It is used to manipulate existing data in the database. The commands in this category are SELECT, UPDATE, INSERT, etc.

3) DCL: It stands for Data control language. It controls access to the data stored in the database. The commands in this category include GRANT and REVOKE.

4) TCL: It stands for Transaction Control Language. It is used to deal with the transaction operations in the database. The commands in this category are COMMIT, ROLLBACK, SET TRANSACTION, SAVEPOINT, etc.


Q5. What is the purpose of DDL Language?

DDL stands for Data definition language. It is the subset of a database that defines the data structure of the database when the database is created. For example, we can use the DDL commands to add, remove, or modify tables. It consists of the commands: CREATE, ALTER and DELETE database objects such as schema, tables, indexes, view, sequence, etc.


Q6. What is the purpose of DML Language?

DML stands for Data manipulation language. It makes the user able to retrieve and manipulate data in a relational database. The DML commands can only perform read-only operations on data. It consists of the commands INSERT, SELECT, UPDATE and DELETE commands to perform the insertion, retrieval, updation and deletion of the records from the database.

Q7. What is the purpose of TCL Language?

TCL stands for Transaction Control Languages. These commands are used for maintaining consistency of the database and for the management of transactions made by the DML commands. A Transaction is a set of SQL statements that are executed on the data stored in DBMS

Q8. What is the purpose of DCL Language?

DCL stands for Data control language. It allows users to control access and permission management to the database. It includes two commands, GRANT and REVOKE.

GRANT: It enables system administrators to assign privileges and roles to the specific user accounts to perform specific tasks on the database.

REVOKE: It enables system administrators to revoke privileges and roles from the user accounts so that they cannot use the previously assigned permission on the database.

Q9. What are tables and fields in the database?

A table is a set of organized data in the form of rows and columns. It enables users to store and display records in the structure format. Columns can categorize as vertical, and Rows are horizontal.

Fields are the components to provide the structure for the table. It stores the same category of data in the same data type. It is also called a column in the table of the database.

Q10. What is a primary key?

A primary key is a field or the combination of fields that uniquely identify each record in the table. It is one of a special kind of unique key. If the column contains a primary key, it cannot be null or empty. It always stores unique values into a column.

Q11. What is a foreign key?

The foreign key is used to link one or more tables together. It is also known as the referencing key. A foreign key is specified as a key that is related to the primary key of another table. It means a foreign key field in one table refers to the primary key field of the other table.

Q12. What is a unique key?

A unique key is a single or combination of fields that ensure all values stores in the column will be unique. It means a column cannot stores duplicate values. This key provides uniqueness for the column or set of columns.

Q13. What is the difference between a primary key and a unique key?

1) We cannot store NULL values in the primary key column. We can store NULL value in the unique key column, but only one NULL is allowed.

2) We cannot change or delete the primary key column values. We can modify the unique key column values.

Q14. What is a Database?

A database is an organized collection of data that is structured into tables, rows, columns, and indexes. It helps the user to find the relevant information frequently. It is an electronic system that makes data access, data manipulation, data retrieval, data storing, and data management very easy.

Q15. Features of database.

Manages large amounts of data

Accurate

Easy to update

Security

Data integrity

Easy to research data

Q16. What is DBMS?

DBMS stands for Database Management System. It is a software program that primarily functions as an interface between the database and the end-user. It provides us the power such as managing the data, the database engine, and the database schema to facilitate the organization and manipulation of data using a simple query in almost no time.

Q17. Components of DBMS.

Software

Data

Procedures

Database Languages

Query Processor

Database Manager

Database Engine

Reporting

Q18. What are the different types of database management systems

Hierarchical databases (DBMS)

Network databases (IDMS)

Relational databases (RDBMS

Object-oriented databases

Document databases (Document DB)

Graph databases

ER model databases

NoSQL databases

Q19. What is RDBMS?

RDBMS stands for Relational Database Management System. It is a database management system based on a relational model. It facilitates you to manipulate the data stored in the tables by using relational operators. RDBMS stores the data into the collection of tables and links those tables using the relational operators easily whenever required.


Q20. What is Normalization in a Database?

Normalization is used to minimize redundancy and dependency by organizing fields and table of a database.

Q21. List the normalization form.

First normal form(1NF)

Second normal form(2NF)

Third normal form(3NF)

Boyce-Codd normal form(BCNF)

Q21. What is the use of Normalization?

Normalization is mainly used to add, delete or modify a field that can be made in a single table. The primary use of Normalization is to remove redundancy and remove the insert, delete and update anomalies. Normalization breaks the table into small partitions and then links them using different relationships to avoid the chances of redundancy.

Q22 What is 1NF form?

First normal form (1NF) is a property of a relation in a relational database. A relation is in first normal form if and only if no attribute domain has relations as elements. It ensuring that there are no repeating groups of data


Q23. What is (2NF) from?

A relation that is in First Normal Form and every non-primary-key attribute is fully functionally dependent on the primary key, then the relation is in Second Normal Form (2NF). A relation must be in first normal form and relation must not contain any partial dependency.  A relation with a single-attribute primary key is automatically in at least 2NF. A relation that is not in 2NF may suffer from the update anomalies.


Q24. What is (3NF) form? 

A relation is in third normal form (3nf), if there is no transitive dependency for non-prime attributes as well as it is in second normal form.

A relation is in 3NF if at least one of the following condition holds in every non-trivial function dependency X –> Y

X is a super key.

Y is a prime attribute (each element of Y is part of some candidate key).

A relation that is in First and Second Normal Form and in which no non-primary-key attribute is transitively dependent on the primary key, then it is in Third Normal Form (3NF).


Q25. Boyce-Codd Normal Form (BCNF).

Boyce-Codd Normal Form or BCNF is an extension to the third normal form. A relation is in BCNF iff, X is a superkey for every functional dependency (FD) X?Y in a given relation. A relation is in BCNF, if and only if, every determinant is a Form (BCNF) candidate key.


Exception Handling Interview Questions

DBMS Interview Questions Set -1

DBMS Interview Questions Set -2

SQL Interview Question Set -1

SQL Interview Question Set -2

JPA Interview Questions Set -1

JPA Interview Question Set -2

Hibernate Interview Questions

Spring Boot Interview Questions Set 1

Spring Boot Interview Questions Set 2

GIT Interview Questions

Redis Interview Questions

Core Java Interview Questions Set -1

Docker interview question Set -1

Docker interview question Set -2

Kubernetes Interview Question Set -1

Kubernetes Interview Question Set -2

No comments:

Post a Comment