DBMS fundamentals you should have a deep understanding of
Here are some DBMS fundamentals you should have a deep understanding of.
◄ Core Concepts
✅ 1. What is the difference between DBMS and RDBMS?
| Feature | DBMS | RDBMS |
|---|---|---|
| Full Form | Database Management System | Relational Database Management System |
| Data Storage | File system / hierarchical / network | Tables (rows and columns) |
| Data Relationships | No | Yes (via foreign keys) |
| Normalization | Not enforced | Enforced to remove redundancy |
| ACID Properties | May not support | Fully supports |
| Example | MS Access, XML DB | MySQL, PostgreSQL, Oracle, SQL Server |
| Use Case | Small-scale apps | Enterprise-scale apps |
✅ Tip: RDBMS is a more advanced form of DBMS.
✅ 2. What are the 3 levels of DBMS architecture?
The three levels of DBMS architecture are:
| Level | Description |
|---|---|
| 1. Internal Level | Describes how data is physically stored (files, indexing, compression). |
| 2. Conceptual Level | Describes the logical structure of the database (tables, relationships, constraints). |
| 3. External Level | Describes user views – what individual users or applications can see and access. |
✅ Known as the Three-Schema Architecture – it supports data abstraction and independence.
✅ 3. What is Data Independence?
Data Independence means the ability to change the schema at one level of the DBMS architecture without affecting the schema at the next higher level.
Types:
| Type | Meaning |
|---|---|
| Logical Data Independence | Change in conceptual schema (like adding a column) doesn't affect external views. |
| Physical Data Independence | Change in internal schema (like indexing, file format) doesn't affect conceptual schema. |
✅ It ensures flexibility and maintainability in database systems.
✅ 4. Difference between SQL and NoSQL
| Feature | SQL (Relational DB) | NoSQL (Non-relational DB) |
|---|---|---|
| Data Structure | Tables (Rows & Columns) | Key-Value, Document, Column, Graph |
| Schema | Fixed schema (structured) | Flexible schema (semi/unstructured) |
| Scalability | Vertical (scale-up) | Horizontal (scale-out) |
| ACID Support | Strong ACID compliance | BASE (Basically Available, Soft state, Eventually consistent) |
| Query Language | SQL (Structured Query Language) | Varies (MongoDB uses JSON-like queries) |
| Example | MySQL, PostgreSQL, Oracle | MongoDB, Cassandra, Redis, Couchbase |
✅ Use SQL for complex queries and strong consistency; use NoSQL for flexible, large-scale, and fast-changing data.
✅ 5. What is a View in SQL?
A view is a virtual table in SQL based on the result of a SELECT query. It doesn't store data itself but displays data from one or more real tables.
🔹 Syntax:
CREATE VIEW view_name AS
SELECT column1, column2 FROM table_name WHERE condition;🔹 Example:
CREATE VIEW active_customers AS
SELECT name, email FROM customers WHERE status = 'active';🔹 Key Points:
| Feature | Description |
|---|---|
| Virtual Table | Doesn’t store data, only shows query result |
| Read-Only or Updatable | Some views can be updated; others are read-only |
| Use Cases | Simplify complex queries, provide security (hide columns), reusable logic |
✅ Views are useful to restrict access, hide sensitive columns, or simplify reporting.
✅ 6. Schema vs Instance
| Concept | Schema | Instance |
|---|---|---|
| Meaning | Structure of the database (tables, columns, data types) | Actual data stored in the database at a given moment |
| Nature | Static – rarely changes | Dynamic – changes frequently |
| Example | Tables: User(id, name, age) | Rows: (1, 'Niraj', 25), (2, 'Amit', 30) |
🎯 Analogy:
Think of a schema as a blueprint of a building, and the instance as the furniture and people inside at a particular time.
✅ 7. Explain ACID Properties
ACID stands for the four key properties of database transactions that ensure data integrity and reliability:
| Property | Meaning | Example |
|---|---|---|
| A – Atomicity | All steps in a transaction succeed, or none do. | Money transfer: debit from A and credit to B must both happen. |
| C – Consistency | DB moves from one valid state to another, preserving rules. | Account balance can’t go negative if a rule exists. |
| I – Isolation | Concurrent transactions don’t interfere. | Two users booking tickets don’t overwrite each other. |
| D – Durability | Once committed, changes are permanent—even after crash. | After "Transaction Success", changes stay even if power goes off. |
✅ ACID ensures that database transactions are safe, reliable, and error-proof.
✅ 8. What is a Constraint in DBMS? What are the Types?
A constraint is a rule applied to table columns to ensure validity, integrity, and consistency of data in a database.
🔹 Common Types of Constraints:
| Constraint Type | Description | Example |
|---|---|---|
| NOT NULL | Ensures a column cannot have NULL values | name VARCHAR(50) NOT NULL |
| UNIQUE | All values in the column must be unique | email VARCHAR(100) UNIQUE |
| PRIMARY KEY | Uniquely identifies each row; cannot be NULL | id INT PRIMARY KEY |
| FOREIGN KEY | Links a column to a primary key in another table | dept_id INT FOREIGN KEY REFERENCES departments(id) |
| CHECK | Ensures a column value meets a condition | salary INT CHECK (salary > 0) |
| DEFAULT | Assigns a default value if no value is provided | status VARCHAR(10) DEFAULT 'active' |
✅ Constraints protect data from invalid, duplicate, or inconsistent entries.
✅ 9. What is a Foreign Key? Why is it Needed?
A foreign key is a column (or set of columns) that creates a relationship between two tables by referencing the primary key of another table.
🔹 Purpose:
- Enforces referential integrity
- Maintains data consistency
- Prevents orphaned records (i.e., child records without a valid parent)
🔹 Example:
-- Parent table
CREATE TABLE Department (
dept_id INT PRIMARY KEY,
dept_name VARCHAR(100)
);
-- Child table
CREATE TABLE Employee (
emp_id INT PRIMARY KEY,
emp_name VARCHAR(100),
dept_id INT,
FOREIGN KEY (dept_id) REFERENCES Department(dept_id)
);✅ A foreign key ensures that an employee must belong to an existing department.
✅ 10. Advantages of Using DBMS Over File System
| Feature | File System | DBMS |
|---|---|---|
| Data Redundancy | High (duplicate data in different files) | Controlled via normalization |
| Data Consistency | Hard to maintain | Easily enforced with constraints |
| Data Integrity | Manual, error-prone | Enforced using constraints (PK, FK, etc.) |
| Security | Minimal or OS-level only | Fine-grained access control (roles, privileges) |
| Concurrent Access | Difficult to manage | Handled with transaction management |
| Backup & Recovery | Manual | Built-in mechanisms for recovery |
| Querying Capability | Limited | Powerful query languages (like SQL) |
✅ DBMS is better for multi-user, secure, and large-scale applications that require data integrity and control.
◄ Keys & Relationships
→ Primary key vs Unique key vs Candidate key?
→ What is a composite key?
→ Super key vs Candidate key?
→ Can a table have multiple foreign keys?
→ What is referential integrity?
→ What is a self-join?
→ What is a Cartesian join?
→ What’s the difference between inner join and outer join?
→ What is a many-to-many relationship?
→ When would you use a junction table?
◄ Normalization
→ What is normalization and why is it needed?
→ 1NF, 2NF, 3NF, BCNF explained with examples?
→ What are the problems with denormalization?
→ When is denormalization actually useful?
→ What is a functional dependency?
→ What is transitive dependency?
→ What is decomposition in DBMS?
→ Lossless decomposition vs lossy?
→ What is redundancy in DBMS?
→ How does normalization remove anomalies?
◄ Indexing & Optimization
→ What is an index in DBMS?
→ Clustered vs Non-clustered index?
→ How does indexing improve performance?
→ Can indexing ever slow things down?
→ What is hashing in DBMS?
→ How does a B+ Tree work?
→ Difference between B Tree and B+ Tree?
→ How is index stored in memory?
→ What is query optimization in DBMS?
→ What is an execution plan in SQL?
◄ Transactions & Concurrency
→ What is a transaction?
→ Explain the ACID properties again with examples.
→ What is concurrency control?
→ What is a deadlock? How do you handle it?
→ What is 2-phase locking protocol?
→ What is serializability?
→ What is cascading rollback?
→ What is write-ahead logging (WAL)?
→ What is optimistic vs pessimistic locking?
→ Why is transaction management important in real-world apps?

