■ DBMS INTERVIEW QUESTIONS WITH DETAILED EASY ANSWERS
1. What is DBMS?
A DBMS is software used to store and manage data. It helps us organize data in tables.
2. What is a Database?
A database is a collection of related data stored in an organized way.
3. What is RDBMS?
RDBMS stores data in tables and uses relationships between them.
4. What is a Table?
A table is a structure with rows and columns.
5. What is a Primary Key?
A primary key uniquely identifies each row.
6. What is a Foreign Key?
A foreign key refers to the primary key of another table.
7. What is a Composite Key?
A key made of two or more columns.
8. What is Normalization?
Organizing data by removing redundancy.
9. What is Denormalization?
Adding redundancy to improve read performance.
10. What is a View?
A virtual table created using SQL SELECT.
11. What is an Index?
Speeds up searching in a table.
12. What is a Transaction?
A group of operations executed together.
13. ACID Properties:
Atomicity, Consistency, Isolation, Durability.
14. What is Deadlock?
Two transactions waiting for each other forever.
15. What is Schema?
Structure of database: tables, columns, datatypes.
■ SQL INTERVIEW QUESTIONS
1. What is SQL?
Language to store, retrieve, and manage data.
2. SQL Commands:
DDL, DML, DQL, DCL, TCL.
3. DELETE vs TRUNCATE vs DROP:
DELETE: removes rows.
TRUNCATE: removes all rows.
DROP: removes table.
4. What is JOIN?
Combines rows from two tables.
5. Types of JOIN:
INNER, LEFT, RIGHT, FULL, SELF, CROSS.
6. GROUP BY:
Groups rows and applies aggregate functions.
7. HAVING:
Filters grouped results.
8. WHERE vs HAVING:
WHERE before grouping; HAVING after grouping.
9. Subquery:
Query inside another query.
10. Stored Procedure:
Saved block of SQL code.
11. Trigger:
Runs automatically on INSERT/UPDATE/DELETE.
12. UNION vs UNION ALL:
UNION removes duplicates; UNION ALL keeps them.
13. CHAR vs VARCHAR:
CHAR fixed; VARCHAR variable length.
14. Cursor:
Processes rows one by one.
■ SQL QUERIES
1. Highest salary:
SELECT MAX(salary) FROM employees;
2. Second highest salary:
SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM employees);
3. Employees per department:
SELECT dept_id, COUNT(*) FROM employees GROUP BY dept_id;
4. Salary above average:
SELECT name FROM employees WHERE salary > (SELECT AVG(salary) FROM employees);