✅ Intermediate
Q5. What is a transaction? Explain ACID properties.
Transaction: sequence of operations performed as a single logical unit.
ACID:
Atomicity – all or nothing
Consistency – db moves from one valid state to another
Isolation – transactions don’t interfere with each other
Durability – changes persist after commit
Q6. What are indexes? Types?
Index improves query performance (like a book’s index).
Types:
Clustered index – data rows are stored in sorted order (only one per table).
Non-clustered index – stores a pointer to the actual data row.
Unique index – ensures uniqueness.
Composite index – index on multiple columns.
⚠️ Tricky part: Too many indexes = slow writes (INSERT/UPDATE/DELETE).
Q7. Difference between UNION and UNION ALL?
UNION: removes duplicates.
UNION ALL: keeps duplicates, faster.
Q8. What is normalization? What are different normal forms?
Normalization: process to remove redundancy & improve consistency.
Normal forms:
1NF – atomic values, no repeating groups
2NF – 1NF + no partial dependency
3NF – 2NF + no transitive dependency
BCNF – stronger form of 3NF