1. What is SQL?
SQL stands for Structured Query Language. It is a programming language used for managing and manipulating relational database.
2. What is database?
A database is an organized collection of data stored and accessed electronically. It provides a way to store, organize, and retrieve large amounts of data efficiently.
3. What is primary key?
A primary key is a column or combination of columns that uniquely identifies each row in a table. It enforces the entity integrity rule in a relational database.
4. What is a foreign key?
A foreign key is a column or combination of columns that establish a link between data in two tables. It ensure referential integrity by enforcing relationships between tables.
5. What is the difference between a primary key and a unique key?
A primary key is used to uniquely identify a row in a table and must have a unique value. On the other hand, a unique key ensures that a column or combination of columns has a unique value but does not necessarily identify the row.
6. What is normalization?
Normalization is the process of organizing data in a database to minimize and dependency. It involves breaking down a table into smaller tables and establishing between them.
7. What are the different types of normalization?
The different types of normalization are:
- First Normal Form (1NF)
- Second Normal Form (2NF)
- Third Normal Form (3NF)
- Boyce-Codd Normal Form (BCNF)
- Fourth Normal Form (4NF)
- Fifth Normal Form (5NF) or Project-Join Normal Form (PJNF)
8. What is a join in SQL?
A join is an operation used to combine rows from two or more tables based on related columns. It allows you to relative data from multiple tables simultaneously.
9. What is the difference between DELETE and TRUNCATE in SQL?
The DELETE statement is used to remove specific rows from a table based on a condition. It can be rolled back and generates individual delete operations for each row.
TRUNCATE, on the other hand, is used to remove all rows from a table. It cannot be rolled back, and it is faster than DELETE as it deallocated the data pages instead of logging individual row deletions.
10. What is the difference between UNION and UNION ALL?
UNION and UNION ALL are used to combine the result sets of two or more SELECT statements.
UNION removes duplicate rows from combined result set.
whereas UNION ALL includes all rows, including duplicates.
11. What is the difference between the HAVING clause and the WHERE clause?
The WHERE clause is used to filter rows based on a condition before the data is grouped or aggregated. It operates on individual rows.
The HAVING clause, on the other hand, is used to filter grouped rows based on a condition after the data is grouped or aggregated using the GROUP BY clause.
12. What is a transaction in SQL?
A transaction is a sequence of SQL statements that are executed as a single logical unit of work. It ensures data consistency and integrity by either committing all changes or rolling them back if an error occurs.
13. What is the difference between a clustered and a non-clustered index?
A clustered index determines the physical order of data in a table. It changes the way the data is stored on disk and can be created on only column. A table can have only one clustered index.
A non-clustered index does not affect the physical order of data in a table. It is stored separately and contains a pointer to the actual data. A table can have multiple non-clustered indexes.
14. What is ACID in the context of database transactions?
ACID stands for Atomicity, Consistency, Isolation, and Durability. It is a set of properties that guarantee reliable processing of database transactions.
Atomicity ensures that a transaction is treated as a single unit of work, either all or none of the changes are applied.
Consistency ensures that a transaction brings the database from one valid state to another.
Isolation ensures that concurrent transactions do not interfere with each other.
Durability ensures that once a transaction is committed, its changes are permanent and survive system failures.
15. What is a deadlock?
A deadlock occurs when two or more transactions are waiting for each other to release resources, resulting in a circular dependency. As a result, none of the transactions can proceed, and the system may become unresponsive.
16. What is the difference between a database and a schema?
A database is a container that holds multiple objects such as tables, views, indexes, and procedures. It represents a logical grouping of related data.
A schema, on the other hand, is a container within a database that holds objects and defines their ownership. It provides a way to organize and manage database objects.
17. What is the purpose of GROUP BY clause?
The GROUP BY clause is used to group rows based on one or more columns in a table. It is typically used in conjunction with aggregate functions, such as SUM, AVG, COUNT, etc., to perform calculations on grouped data.
Read More Topics |
Python data science interview questions |
PHP Interview questions and answers |
JAVA Interview questions and answers |