DBMS Interview Questions
Q1: What is the difference between DBMS and RDBMS?
**DBMS** (Database Management System) stores data as files. **RDBMS** (Relational DBMS) stores data in tables with relationships.
| Feature | DBMS | RDBMS ||---------|------|-------|
| Data Storage | File-based | Table-based | | Relationships | No | Yes (Foreign Keys) | | Normalization | Not supported | Supported | | ACID | Partial | Full | | Example | MongoDB | PostgreSQL |Q2: Explain the ACID properties.
**Atomicity**: Transaction is all-or-nothing. If any part fails, the entire transaction rolls back.
**Consistency**: Transaction brings database from one valid state to another. All constraints and rules are maintained.
**Isolation**: Concurrent transactions don't interfere with each other. Each transaction appears to run in isolation.
**Durability**: Once committed, changes persist even after system failure.
Q3: What is normalization? Explain normal forms.
Normalization is the process of organizing data to eliminate redundancy and anomalies.
**1NF**: Atomic columns, no repeating groups
**2NF**: 1NF + no partial dependencies
**3NF**: 2NF + no transitive dependencies
**BCNF**: Every determinant is a candidate key
**4NF**: No multi-valued dependencies
**Example**:
Before normalization: Student(ID, Name, Courses)
After 3NF: Student(ID, Name), Enrollment(ID, CourseID), Course(CourseID, Name)
Q4: What is indexing? Types of indexes?
Indexing is a technique to speed up data retrieval operations.
**Types**:
Q5: Explain SQL Joins.
**INNER JOIN**: Returns matching rows from both tables
**LEFT JOIN**: All rows from left, matching from right
**RIGHT JOIN**: All rows from right, matching from left
**FULL OUTER JOIN**: All rows from both tables
**CROSS JOIN**: Cartesian product
**SELF JOIN**: Table joined with itself
Q6: What is a transaction and its states?
A transaction is a logical unit of work that contains one or more SQL statements.
**States**: Active → Partially Committed → Committed
→ Failed → Aborted
Q7: Difference between DELETE, TRUNCATE, and DROP?
| Command | Type | Speed | Rollback | Structure ||---------|------|-------|----------|-----------|
| DELETE | DML | Slow | Yes | Preserved | | TRUNCATE | DDL | Fast | No | Preserved | | DROP | DDL | Fastest | No | Removed |Q8: What is a deadlock in databases?
A deadlock occurs when two or more transactions hold locks on resources that each other needs, causing them to wait indefinitely.
**Solutions**: