DBMS fundamentals you should have a deep understanding of

Anonymous User
507
Aug 03, 2025
Aug 04, 2025

Here are some DBMS fundamentals you should have a deep understanding of.

◄ Core Concepts


✅ 1. What is the difference between DBMS and RDBMS?

FeatureDBMSRDBMS
Full FormDatabase Management SystemRelational Database Management System
Data StorageFile system / hierarchical / networkTables (rows and columns)
Data RelationshipsNoYes (via foreign keys)
NormalizationNot enforcedEnforced to remove redundancy
ACID PropertiesMay not supportFully supports
ExampleMS Access, XML DBMySQL, PostgreSQL, Oracle, SQL Server
Use CaseSmall-scale appsEnterprise-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:

LevelDescription
1. Internal LevelDescribes how data is physically stored (files, indexing, compression).
2. Conceptual LevelDescribes the logical structure of the database (tables, relationships, constraints).
3. External LevelDescribes 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:

TypeMeaning
Logical Data IndependenceChange in conceptual schema (like adding a column) doesn't affect external views.
Physical Data IndependenceChange 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

FeatureSQL (Relational DB)NoSQL (Non-relational DB)
Data StructureTables (Rows & Columns)Key-Value, Document, Column, Graph
SchemaFixed schema (structured)Flexible schema (semi/unstructured)
ScalabilityVertical (scale-up)Horizontal (scale-out)
ACID SupportStrong ACID complianceBASE (Basically Available, Soft state, Eventually consistent)
Query LanguageSQL (Structured Query Language)Varies (MongoDB uses JSON-like queries)
ExampleMySQL, PostgreSQL, OracleMongoDB, 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:

FeatureDescription
Virtual TableDoesn’t store data, only shows query result
Read-Only or UpdatableSome views can be updated; others are read-only
Use CasesSimplify complex queries, provide security (hide columns), reusable logic

✅ Views are useful to restrict access, hide sensitive columns, or simplify reporting.


✅ 6. Schema vs Instance

ConceptSchemaInstance
MeaningStructure of the database (tables, columns, data types)Actual data stored in the database at a given moment
NatureStatic – rarely changesDynamic – changes frequently
ExampleTables: 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:

PropertyMeaningExample
A – AtomicityAll steps in a transaction succeed, or none do.Money transfer: debit from A and credit to B must both happen.
C – ConsistencyDB moves from one valid state to another, preserving rules.Account balance can’t go negative if a rule exists.
I – IsolationConcurrent transactions don’t interfere.Two users booking tickets don’t overwrite each other.
D – DurabilityOnce 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 TypeDescriptionExample
NOT NULLEnsures a column cannot have NULL valuesname VARCHAR(50) NOT NULL
UNIQUEAll values in the column must be uniqueemail VARCHAR(100) UNIQUE
PRIMARY KEYUniquely identifies each row; cannot be NULLid INT PRIMARY KEY
FOREIGN KEYLinks a column to a primary key in another tabledept_id INT FOREIGN KEY REFERENCES departments(id)
CHECKEnsures a column value meets a conditionsalary INT CHECK (salary > 0)
DEFAULTAssigns a default value if no value is providedstatus 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

FeatureFile SystemDBMS
Data RedundancyHigh (duplicate data in different files)Controlled via normalization
Data ConsistencyHard to maintainEasily enforced with constraints
Data IntegrityManual, error-proneEnforced using constraints (PK, FK, etc.)
SecurityMinimal or OS-level onlyFine-grained access control (roles, privileges)
Concurrent AccessDifficult to manageHandled with transaction management
Backup & RecoveryManualBuilt-in mechanisms for recovery
Querying CapabilityLimitedPowerful 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?

Comments (1)