Computer Science
DBMS Master Revision Handbook
🗄️ DBMS / SQL — Master Revision Handbook
Database Management System | SQL | NoSQL | RDBMS | Architecture | Design
🚨 15+ Answer Key Bugs Detected & Fixed
📊 467 MCQs Analyzed
🎯 Exam-Ready | Hindi
⭐ High-Yield Only
🚨 EXAM TRAPS & ANSWER KEY BUGS — सर्वोच्च प्राथमिकता
🚨 Answer Key Bugs — गलत उत्तर चिह्नित हैं (Book WRONG → Correct सही)
| विषय | प्रश्न (संक्षिप्त) | Book (❌) | Correct (✅) | कारण |
|---|---|---|---|---|
| Basic | Data कहाँ store होता है? | (b) DBMS में | (d) Database में | DBMS = Manager, Database = Storage. दोनों अलग हैं। |
| DB Models | सबसे पुराना DB model? | (c) Network | (a) Hierarchical | Hierarchical पहले आया (IBM IMS 1960s), फिर Network। |
| RDBMS | 'Attribute' क्या होता है? | (b) Tuple (Row) | (a) Column | Attribute = Column/Field। Tuple = Row। सबसे ज़्यादा confuse होने वाला trap। |
| RDBMS | Relational Model किससे संबंधित? | (b) Structure+Integrity | (c) Both a and b (सभी) | Data Manipulation भी Relational Model का हिस्सा है। |
| Keys | Student table में Primary Key? | (b) Dept | (c) ID | Dept एक से ज़्यादा students में share होता है — PK नहीं बन सकता। |
| Keys | Rows क्या कहलाती हैं? | (a) Relation | (b) Tuples | Relation = Table (पूरी), Tuple = Row। Book बिल्कुल गलत। |
| Keys | FK — Referencing vs Referenced? | Referencing | Referenced | FK रखने वाली table = Referencing; FK जहाँ point हो = Referenced। |
| Rela. Types | Relational DB में किस type के relations? | (c) Flat | (b) Normalized | Flat-file और Relational DB अलग concepts हैं। |
| Rel. Degree | Relationship degree के types? | (a) Binary only | (d) All of above | Unary, Binary, Ternary, N-ary — सभी valid degree types हैं। |
| DB Design | E-R Model किसने दिया? | Dr. Edgar F. Codd | Peter Chen (1976) | 🚨 MAJOR TRAP: Codd = Relational Model, Peter Chen = ER Model। |
| Design | Relational Model में tables को क्या कहते? | (b) Records | (c) Relations | "Relational" शब्द ही answer देता है — tables = Relations। |
| DDL/DML | DDL नहीं है कौनसा? (SQL में) | (a) RENAME only | (d) UPDATE | RENAME = DDL (structure change)। UPDATE = DML (data change)। |
| DDL/DML | DML नहीं है कौनसा? | (b) CREATE | (d) TRUNCATE | TRUNCATE = DDL। CREATE भी DDL। Book ने गलत option mark किया। |
| NoSQL | MongoDB किसमें लिखा गया? | (a) JavaScript | (b) C++ | MongoDB का core engine C++ में है। Query language JS है। |
| NoSQL | DELETE rows के लिए SQL command? | (d) REMOVE | (a) DELETE | REMOVE कोई valid SQL command नहीं है। |
| NoSQL | NoSQL databases को refer किया जाता है? | (b) Non-relational | (c) "Not Only SQL" | NoSQL = "Not Only SQL" — official correct expansion। |
| Manipulating | Record management primitives? | (c) Look-up only | (d) All of above | Add, Delete, Look-up — तीनों primitive operations हैं। |
| GRANT/REVOKE | GRANT/REVOKE किसमें आते हैं? | कई books में DDL | DCL (Data Control Language) | 🚨 Mock Test bug: GRANT/REVOKE = हमेशा DCL, कभी DDL नहीं। |
⚠️ सबसे ज़्यादा Confuse होने वाले TRAPS
Attribute vs Tuple — सबसे ज़्यादा गलती
Attribute = Column/Field (vertical)
Tuple = Row/Record (horizontal)
Relation = Table (complete 2D)
🧠 A-ttribute = A column। T-uple = T-able row।
Attribute = Column/Field (vertical)
Tuple = Row/Record (horizontal)
Relation = Table (complete 2D)
🧠 A-ttribute = A column। T-uple = T-able row।
Referenced vs Referencing Relation
Referencing relation = जिसमें FK रखा जाता है (doing the referencing)
Referenced relation = जहाँ PK होती है जिसे FK point करता है
🧠 "Who has the FK" = Referencing। "Who has the PK" = Referenced।
Referencing relation = जिसमें FK रखा जाता है (doing the referencing)
Referenced relation = जहाँ PK होती है जिसे FK point करता है
🧠 "Who has the FK" = Referencing। "Who has the PK" = Referenced।
ACID — Atomicity vs Durability Timeline Trap
Transaction के दौरान failure → Atomicity (Rollback)
Transaction Commit के बाद crash → Durability (Persist)
🧠 "Transaction सफल के बाद भी safe" = Durability (not Atomicity!)
Transaction के दौरान failure → Atomicity (Rollback)
Transaction Commit के बाद crash → Durability (Persist)
🧠 "Transaction सफल के बाद भी safe" = Durability (not Atomicity!)
ER Model — Aggregation Trap
"Relationships are treated as higher-level entities" पढ़ते ही Aggregation चुनो
Generalization ≠ Aggregation
🧠 Entity का एकीकरण = Generalization; Relationship का एकीकरण = Aggregation
"Relationships are treated as higher-level entities" पढ़ते ही Aggregation चुनो
Generalization ≠ Aggregation
🧠 Entity का एकीकरण = Generalization; Relationship का एकीकरण = Aggregation
WHERE vs HAVING — Aggregate Function
🧠 W comes before H। WHERE = Worker level, HAVING = Head/Group level
WHERE AVG(Salary) > 5000 ❌ Error देगाHAVING AVG(Salary) > 5000 ✅ सही🧠 W comes before H। WHERE = Worker level, HAVING = Head/Group level
UNION vs UNION ALL — Performance
UNION ALL > UNION (performance में तेज़)
क्योंकि UNION ALL sorting नहीं करता
🧠 UNION ALL = All Includes (बिना छानबीन)। UNION = Unique (extra work)
UNION ALL > UNION (performance में तेज़)
क्योंकि UNION ALL sorting नहीं करता
🧠 UNION ALL = All Includes (बिना छानबीन)। UNION = Unique (extra work)
Codd vs Peter Chen — कभी मत भूलो
Edgar F. Codd → Relational Model (1970)
Peter Chen → E-R Model (1976)
Charles Bachman → First DBMS (IDS)
🧠 C for Codd = C for Columns/Relational। Chen = E-R = Entity Relationship
Edgar F. Codd → Relational Model (1970)
Peter Chen → E-R Model (1976)
Charles Bachman → First DBMS (IDS)
🧠 C for Codd = C for Columns/Relational। Chen = E-R = Entity Relationship
TRUNCATE — DDL या DML?
TRUNCATE = DDL (हमेशा)
Auto-committed है, Rollback नहीं होता
DELETE = DML, Rollback हो सकता है
🧠 TRUNCATE = Table Reset (structure change style)।
TRUNCATE = DDL (हमेशा)
Auto-committed है, Rollback नहीं होता
DELETE = DML, Rollback हो सकता है
🧠 TRUNCATE = Table Reset (structure change style)।
MySQL Full Outer Join Trap — "FULL OUTER JOIN हर Database में support होता है" → गलत
MySQL में FULL OUTER JOIN directly support नहीं होता। Method:
MySQL में FULL OUTER JOIN directly support नहीं होता। Method:
LEFT JOIN ... UNION ... RIGHT JOIN
📚 CORE CONCEPTS — Rapid Revision
1. DBMS — मूल परिचय
| Term | Full Form / अर्थ |
|---|---|
| DBMS | Database Management System |
| RDBMS | Relational DBMS (tables में) |
| DDL | Data Definition Language |
| DML | Data Manipulation Language |
| DCL | Data Control Language |
| TCL | Transaction Control Language |
| DQL | Data Query Language (SELECT) |
| Important Persons | Contribution |
|---|---|
| Charles Bachman | World's First DBMS (IDS, 1960) |
| Edgar F. Codd | Relational Model (1970), 12 Rules |
| Peter Chen | E-R Model (1976) |
| Carlo Strozzi | "NoSQL" term (1998) |
🧠 B→C→P: Bachman (First DBMS) → Codd (Relational) → Peter Chen (ER Model)
2. DB Models — तुलना ⭐⭐
| Model | Structure | Relations | Example | कब efficient |
|---|---|---|---|---|
| Hierarchical | Tree (oldest) | One-to-Many, ONE parent per child | IBM IMS | Small transactions + Large data |
| Network | Graph | Many-to-Many, MULTIPLE parents allowed | CODASYL | Complex relationships |
| Relational | Tables (Relations) | All types via FK/joins | MySQL, Oracle | General purpose (most used) |
| Object-Oriented | Objects | Class hierarchy | ObjectDB | Complex data types |
🧠 Hierarchical = Family Tree (एक parent per child)। Network = Social Network (multiple parents)। "H before N" in alphabet = Hierarchical before Network (history wise)
3. ANSI/SPARC Three-Schema Architecture ⭐⭐
External Schema
= User View (partial)
External users जो देखते हैं
Multiple views हो सकती हैं
= User View (partial)
External users जो देखते हैं
Multiple views हो सकती हैं
Conceptual Schema
= Complete Logical View
DBA के लिए entire DB का view
एक ही होती है
= Complete Logical View
DBA के लिए entire DB का view
एक ही होती है
Internal Schema
= Physical Storage Structure
Disk पर कैसे store होगा
एक ही होती है
= Physical Storage Structure
Disk पर कैसे store होगा
एक ही होती है
⚠️ Trap: 'Implementation Schema' — यह EXIST नहीं करता। Internal Schema = ANSI/SPARC में है, Implementation नहीं।
🧠 ECI = External, Conceptual, Internal — तीन real schemas।
🧠 ECI = External, Conceptual, Internal — तीन real schemas।
4. Keys — Complete Summary ⭐⭐⭐
| Key Type | परिभाषा | Rules |
|---|---|---|
| Primary Key (PK) | Unique + NOT NULL — एक table में एक ही | NULL❌, Duplicate❌ |
| Foreign Key (FK) | दूसरी table की PK को refer करे | Referential Integrity |
| Candidate Key | Uniquely identify कर सके — सभी possible keys | एक table में multiple हो सकती हैं |
| Alternate Key | Candidate Keys जो PK नहीं बनीं | — |
| Unique Key | Unique values ensure करे | NULL✅ (one allowed), Duplicate❌ |
| Composite Key | दो या अधिक columns मिलकर PK | — |
| Super Key | Candidate Key के superset (extra attributes के साथ) | — |
Primary = ONE per table, NO NULL | Unique = ONE NULL allowed | Candidate Keys = Multiple | All Candidate keys can uniquely identify rows
5. DDL / DML / DCL / TCL ⭐⭐⭐
| Category | Full Form | Commands | Auto-Commit? | Rollback? |
|---|---|---|---|---|
| DDL | Data Definition Language | CREATE, ALTER, DROP, TRUNCATE, RENAME | ✅ हाँ | ❌ नहीं |
| DML | Data Manipulation Language | SELECT, INSERT, UPDATE, DELETE | ❌ नहीं | ✅ हाँ |
| DCL | Data Control Language | GRANT, REVOKE | ✅ हाँ | ❌ नहीं |
| TCL | Transaction Control Language | COMMIT, ROLLBACK, SAVEPOINT | — | — |
🚨 Bug: GRANT/REVOKE = हमेशा DCL। कई mock tests में इसे DDL में डाल देते हैं — गलत।
TRUNCATE vs DELETE vs DROP ⭐⭐
| Feature | TRUNCATE | DELETE | DROP |
|---|---|---|---|
| Category | DDL | DML | DDL |
| क्या हटाता है | सभी Rows (data) | Specific rows (WHERE से) | पूरी Table structure + data |
| Rollback | ❌ नहीं | ✅ हाँ | ❌ नहीं |
| Log | Minimal logging | Full row-level logging | — |
| Speed | तेज़ | धीमा (per row) | — |
| Table Structure | बना रहता है | बना रहता है | हट जाता है |
💻 SQL — Complete Exam Reference
SQL Execution Order ⭐⭐⭐ — सबसे ज़्यादा पूछा जाता है
FROM → JOIN → WHERE → GROUP BY → HAVING → SELECT → DISTINCT → ORDER BY → LIMIT/TOP
- FROM = Source table पहचानना
- WHERE = Individual rows filter (Aggregates नहीं)
- GROUP BY = Groups बनाना
- HAVING = Groups filter (Aggregates यहाँ)
- SELECT = Columns चुनना (Alias यहाँ define होता है)
- ORDER BY = Sort करना (SELECT alias यहाँ use हो सकता है)
- Alias को WHERE में USE नहीं कर सकते — SELECT बाद में execute होता है
WHERE vs HAVING ⭐⭐
| Feature | WHERE | HAVING |
|---|---|---|
| Filter करता है | Individual Rows (Row-level) | Groups (Group-level) |
| कब execute होता है | GROUP BY से पहले | GROUP BY के बाद |
| Aggregate Functions | ❌ नहीं (Error) | ✅ हाँ (SUM, COUNT, AVG...) |
| बिना GROUP BY | अकेले काम करता है | पूरी table को 1 group मानता है |
SQL Execution Order Trick: Fw Gh So
FROM → WHERE → GROUP BY → HAVING → SELECT → ORDER BY
FROM → WHERE → GROUP BY → HAVING → SELECT → ORDER BY
JOINs ⭐⭐⭐
| JOIN Type | Returns | Unmatched Rows |
|---|---|---|
| INNER JOIN | केवल Common (matching) records | पूरी तरह गायब |
| LEFT OUTER JOIN | Left table सभी + Right matching | Right side → NULL |
| RIGHT OUTER JOIN | Right table सभी + Left matching | Left side → NULL |
| FULL OUTER JOIN | दोनों tables सभी records | दोनों तरफ NULL possible |
| CROSS JOIN | Cartesian Product (m × n) | कोई condition नहीं |
| SELF JOIN | Table खुद से join | Alias अनिवार्य (e1, e2) |
| NATURAL JOIN | Common column name पर auto join | No common column → CROSS JOIN |
🧠 Keyword trap: "even if doesn't exist / all records regardless" → LEFT या RIGHT JOIN चुनो (जो 'All' वाली table उस side हो)
⚠️ INNER JOIN Maximum rows ≤ m × n (Cartesian Product)। कभी exceed नहीं होगा।
MySQL में FULL OUTER JOIN नहीं होता → LEFT JOIN + UNION + RIGHT JOIN
MySQL में FULL OUTER JOIN नहीं होता → LEFT JOIN + UNION + RIGHT JOIN
Set Operations ⭐⭐
| Operator | Output | Duplicates | Performance | Commutative? |
|---|---|---|---|---|
| UNION | दोनों की सभी unique rows | Remove करता है | Slow (sorting) | ✅ A∪B = B∪A |
| UNION ALL | दोनों की सभी rows | रखता है (Keeps) | Fast ⚡ | ✅ A∪B = B∪A |
| INTERSECT | केवल Common rows | Remove करता है | Slow | ✅ A∩B = B∩A |
| MINUS/EXCEPT | पहले में से दूसरे को घटाओ | Remove करता है | Slow | ❌ A-B ≠ B-A |
Set Operations की अनिवार्य शर्तें: ① दोनों queries में columns की संख्या समान ② Corresponding columns का data type compatible ③ Column names समान होना ज़रूरी नहीं (output = पहली query के column names)
ORDER BY केवल पूरी query के अंत में एक बार (individual SELECTs के साथ नहीं)
ORDER BY केवल पूरी query के अंत में एक बार (individual SELECTs के साथ नहीं)
Subquery / Nested Query ⭐⭐
- Inner Query पहले execute होती है
- Inner Query result = Outer Query को देती है
- WHERE या HAVING में use होती है
- ANY = कम से कम एक से match (OR)
- ALL = सभी से match (AND)
- EXISTS = TRUE/FALSE (row exist करे तो TRUE)
🧠 ANY vs ALL:
ANY = At least one (OR condition)
ALL = Every single one (AND condition)
ANY = At least one (OR condition)
ALL = Every single one (AND condition)
WHERE salary > ALL(subquery) = सबसे ज़्यादा MAX से भी ज़्यादाWHERE salary > ANY(subquery) = कम से कम MIN से ज़्यादा
NOT IN vs NOT EXISTS — Null Trap ⭐
⚠️ Important: अगर Subquery में NULL आए तो:
NOT IN → पूरा result empty/NULL हो जाता है (NULL से compare = unknown)
NOT EXISTS → NULL का कोई ऐसा effect नहीं पड़ता (safer)
NOT IN → पूरा result empty/NULL हो जाता है (NULL से compare = unknown)
NOT EXISTS → NULL का कोई ऐसा effect नहीं पड़ता (safer)
Indexing ⭐⭐
| Feature | With Index | Without Index |
|---|---|---|
| Read (SELECT) | ✅ Fast — O(log N) | ❌ Slow — Full Table Scan O(N) |
| Write (INSERT/UPDATE) | ❌ Slower (index update) | ✅ Faster |
| Storage | ❌ Extra space लेता है | ✅ कम space |
🧠 Index = Read Fast, Write Slow | Index = Extra Storage (reduces nothing)
File Organization: Hash vs B+ Tree ⭐⭐
| Feature | Hash Organization | B+ Tree Organization |
|---|---|---|
| Structure | Hash Table / Buckets | Balanced Search Tree (Leaf nodes linked) |
| Best for | Exact Match (WHERE id = 10) | Range Query (BETWEEN, >, <, ORDER BY) |
| Sorting/ORDER BY | ❌ नहीं (unsupported) | ✅ हाँ (efficient) |
| Time Complexity | O(1) average | O(log N) |
⚠️ Trap: "Hash O(1) है तो हमेशा बेहतर" — गलत। Range queries और ORDER BY में B+ Tree ही काम करता है।
🧠 Hash = Handshake (Exact person) | B+ Tree = Between/Bigger-Smaller (Range)
🧠 Hash = Handshake (Exact person) | B+ Tree = Between/Bigger-Smaller (Range)
🔄 ACID Properties & Transactions
ACID Properties ⭐⭐⭐
| Property | Core Meaning | Exam Keyword | Responsible Component |
|---|---|---|---|
| Atomicity | All or Nothing — पूरा या कुछ नहीं | Rollback / Transaction के दौरान failure | Recovery Manager |
| Consistency | DB के नियम (constraints) कभी नहीं टूटेंगे | Valid State / Integrity Constraints | User / Programmer |
| Isolation | Concurrent transactions एक-दूसरे को disturb नहीं करते | Dirty Read / Concurrent execution | Concurrency Control (Locks) |
| Durability | Commit के बाद crash में भी data safe | System Failure / Persist / Disk | Recovery Manager (Log) |
🚨 Timeline Trap:
Transaction के दौरान failure → Rollback → Atomicity
Transaction Commit के बाद crash → Data persist रहे → Durability
"Dirty Read problem" = Isolation का उल्लंघन
Transaction के दौरान failure → Rollback → Atomicity
Transaction Commit के बाद crash → Data persist रहे → Durability
"Dirty Read problem" = Isolation का उल्लंघन
Concurrency Control Anomalies ⭐
| Anomaly | क्या होता है | Solution |
|---|---|---|
| Dirty Read | Uncommitted data को दूसरा पढ़ ले | Isolation / Locking |
| Non-Repeatable Read | Same query, अलग result (update के बाद) | Higher Isolation Level |
| Phantom Read | Same query, नई rows appear हों (insert के बाद) | Serializable Isolation |
| Lost Update | दो transactions एक-दूसरे का update overwrite करें | Locking |
Cascading Rollback ⭐
Cascading Rollback: एक Transaction (T₁) fail → उसका Dirty Read करने वाले सभी Transactions (T₂, T₃...) भी Rollback होंगे → Chain Reaction
कारण: Dirty Read (Uncommitted Dependency)
बचाव: Cascadeless Schedule — कोई भी transaction, दूसरे का uncommitted data नहीं पढ़ सकता
Hierarchy: Strict ⊂ Cascadeless ⊂ Recoverable
🧠 Cascading = Waterfall (ऊपर गिरा तो नीचे सब गिरे)
कारण: Dirty Read (Uncommitted Dependency)
बचाव: Cascadeless Schedule — कोई भी transaction, दूसरे का uncommitted data नहीं पढ़ सकता
Hierarchy: Strict ⊂ Cascadeless ⊂ Recoverable
🧠 Cascading = Waterfall (ऊपर गिरा तो नीचे सब गिरे)
Transaction States
Active → Partially Committed → Committed (success) | Active → Failed → Aborted (rollback)
📐 ER Model & Database Design
ER Diagram Symbols ⭐⭐⭐
| Symbol | Represents | Example |
|---|---|---|
| Rectangle (आयत) | Entity | Student, Employee |
| Double Rectangle (दोहरी आयत) | Weak Entity | Dependent (of Employee) |
| Diamond (हीरा) | Relationship | Works-In |
| Ellipse (दीर्घवृत्त) | Attribute | Name, Age |
| Double Ellipse | Multivalued Attribute | Phone Numbers |
| Dotted Ellipse | Derived Attribute | Age (from DOB) |
| Underlined in Ellipse | Key Attribute | Student_ID |
| Dashed Rectangle | Aggregation | Relationship acting as Entity |
🧠 Diamond = Relationship (diamond ring connects two people) | Rectangle = Entity | Ellipse = Attribute | Double = Weak/Multivalued
Generalization vs Specialization vs Aggregation ⭐⭐
| Concept | Approach | क्या होता है | ER Symbol |
|---|---|---|---|
| Generalization | Bottom-Up ↑ | कई entities → एक Higher Entity | Triangle (ISA) |
| Specialization | Top-Down ↓ | एक entity → कई sub-entities | Triangle (ISA) |
| Aggregation | Abstraction | Relationship → Higher Entity बन जाए | Dashed Rectangle |
⚠️ "Relationships treated as higher-level entities" → Aggregation (Generalization नहीं!)
🧠 Ground→Sky = Generalization (Bottom-Up) | Sky→Ground = Specialization (Top-Down) | RA = Relationship to Aggregation
🧠 Ground→Sky = Generalization (Bottom-Up) | Sky→Ground = Specialization (Top-Down) | RA = Relationship to Aggregation
Strong Entity vs Weak Entity
Strong Entity:
✅ अपनी Primary Key होती है
✅ स्वतंत्र रूप से exist करती है
Symbol: Single Rectangle
✅ अपनी Primary Key होती है
✅ स्वतंत्र रूप से exist करती है
Symbol: Single Rectangle
Weak Entity:
❌ Primary Key नहीं होती
❌ Strong entity पर depend करती है
Symbol: Double Rectangle (दोहरी)
Discriminator/Partial key होती है
❌ Primary Key नहीं होती
❌ Strong entity पर depend करती है
Symbol: Double Rectangle (दोहरी)
Discriminator/Partial key होती है
Normalization ⭐
| Normal Form | Condition |
|---|---|
| 1NF | कोई Repeating Groups नहीं, Atomic values (Multivalued attribute नहीं) |
| 2NF | 1NF + No Partial Dependency (Non-key attributes पूरी PK पर depend) |
| 3NF | 2NF + No Transitive Dependency |
| BCNF | 3NF + हर determinant एक Candidate Key होनी चाहिए |
🌐 NoSQL Technology
NoSQL — परिचय ⭐⭐
- NoSQL = "Not Only SQL" (NOT "Non-relational" ❌)
- Schema-free — पहले structure define नहीं करना
- Join-free — tables join नहीं होती
- Big Data के लिए बना — Unstructured data
- High Availability through distributed architecture
- SQL से ज़्यादा flexible और faster development
| NoSQL Types | Examples |
|---|---|
| Document | MongoDB, CouchDB |
| Key-Value | Redis, DynamoDB (simplest) |
| Column | Cassandra, HBase |
| Graph | Neo4j |
🧠 D-K-C-G: Document, Key-value, Column, Graph
NoSQL vs SQL (RDBMS) ⭐
| Feature | SQL (RDBMS) | NoSQL |
|---|---|---|
| Schema | Fixed (predefined) | Flexible / Schema-free |
| ACID | ✅ Full ACID compliance | ❌ Generally BASE (eventually consistent) |
| Scaling | Vertical (scale up) | Horizontal (scale out) |
| Data Model | Tables (Relations) | Document/Key-value/Graph/Column |
| Joins | ✅ Complex joins | ❌ Usually no joins |
| Storage | Row-based | Document=JSON/BSON; KV=Key-Value pairs |
MongoDB Specifics ⭐
| MongoDB Term | RDBMS Equivalent |
|---|---|
| Collection | Table |
| Document | Row / Record |
| Field | Column / Attribute |
| _id | Primary Key |
MongoDB core engine = C++ में लिखा है (JavaScript नहीं ❌ — JS shell के लिए है)
NoSQL Answer Key Bugs ⭐
🚨 Confirmed Bugs in NoSQL Questions:
① Impala = Cloudera का NoSQL tool (HBase नहीं) ✅
② NoSQL का aim = Non-relational data manage करना (broader claims गलत)
③ NoSQL से data extract = Query लिखनी और run दोनों करनी होती है
④ NoSQL = "Not Only SQL" (Non-relational नहीं — यह limited definition है)
⑤ TRUNCATE = DDL (book कई बार DML में count करती है — गलत)
① Impala = Cloudera का NoSQL tool (HBase नहीं) ✅
② NoSQL का aim = Non-relational data manage करना (broader claims गलत)
③ NoSQL से data extract = Query लिखनी और run दोनों करनी होती है
④ NoSQL = "Not Only SQL" (Non-relational नहीं — यह limited definition है)
⑤ TRUNCATE = DDL (book कई बार DML में count करती है — गलत)
🏗️ Architecture & Advanced Concepts
Database Architecture Types ⭐
| Architecture | Description | Use Case |
|---|---|---|
| 1-Tier | Standalone — DB, application, user एक ही machine | Local development |
| 2-Tier | Client-Server — Client application directly DB server से | Traditional enterprise apps |
| 3-Tier | Client + Application Server + DB Server | Web applications |
Server Processes ⭐
| Process | काम |
|---|---|
| Server Process | Queries execute करना, results client को return करना |
| Lock Manager | Lock grant, release, Deadlock detection |
| DB Writer Process | Buffer से disk पर data write करना |
| Log Writer Process | Transaction log write करना |
Transaction-server system = Query-server system (Server side SQL process करता है)
Parallel Databases ⭐
Coarse-Granularity Parallelism:
Few processors (general-purpose)
Large data chunks
Few processors (general-purpose)
Large data chunks
Fine-Granularity Parallelism:
Many specialized processors
Tiny data chunks
Degree of Parallelism = एक operation पर कितने parallel servers
Many specialized processors
Tiny data chunks
Degree of Parallelism = एक operation पर कितने parallel servers
Database Sharding vs Federation ⭐
| Feature | Sharding | Federation |
|---|---|---|
| Nature | Homogeneous (same schema) | Heterogeneous (different schemas) |
| What splits | एक DB की Rows — अलग servers पर | कई independent DBs को एक window से जोड़ना |
| Autonomy | ❌ Shards independent नहीं | ✅ Each DB fully autonomous |
| Coupling | Tightly coupled | Loosely coupled |
🧠 Federation = Freedom (हर DB अपना boss) | Sharding = Shredding (एक DB को काट दिया rows में)
Important DBMS Facts — Quick Recall ⭐⭐
| Topic | Key Fact |
|---|---|
| Data Dictionary | Metadata के बारे में metadata = System Catalog। DB के सभी objects describe करता है। |
| Buffer | Disk-to-Memory transfers minimize करता है। RAM में data cache। |
| DBA | Database Performance के लिए सबसे ज़्यादा जिम्मेदार |
| Data Mining | Database पर directly काम करके patterns/knowledge निकालना |
| Dynaset | MS Access में query का result = Dynamic Set of records |
| Search Engine है, DBMS नहीं (DBMS = Oracle, MySQL, DB2, MS Access) | |
| Cloud: On-Demand | Human interaction के बिना resources provision करना = On-Demand Self-Service |
| Data Hierarchy | Bit → Byte → Field → Record → File → Database |
| Master File | Original/Primary permanent data file of a system |
| Embedded SQL | SQL code inside 3GL programs (C, Java, COBOL) |
📌 One-Line Revision — Last Minute Rapid Recall
| Topic | One-Line Fact |
|---|---|
| DBMS vs Database | DBMS = Manager/Software, Database = Storage. दोनों अलग। |
| Hierarchical (Oldest) | IMS (IBM, 1960s)। Tree। One parent per child। |
| Network | Graph। Multiple parents per child। CODASYL। |
| Relational | Tables = Relations। Set concept। SQL। Codd ने बनाया। |
| Primary Key | Unique + NOT NULL। एक table में एक ही। |
| Foreign Key | दूसरी table की PK। Parent-Child relationship। |
| Unique Key | Unique। एक NULL allowed। |
| DDL | CREATE ALTER DROP TRUNCATE RENAME — Structure बदलता है। |
| DML | SELECT INSERT UPDATE DELETE — Data बदलता है। |
| DCL | GRANT REVOKE — Permissions control। |
| TCL | COMMIT ROLLBACK SAVEPOINT — Transaction control। |
| TRUNCATE | DDL। Auto-committed। Rollback नहीं। |
| WHERE | Rows filter। GROUP BY से पहले। Aggregates नहीं। |
| HAVING | Groups filter। GROUP BY के बाद। Aggregates ✅। |
| INNER JOIN | केवल matching records। |
| LEFT JOIN | Left table सभी + Right NULL। |
| CROSS JOIN | Cartesian Product = m × n। |
| UNION | Duplicates हटाकर combine। Slow। |
| UNION ALL | Duplicates रखकर combine। Fast। |
| INTERSECT | केवल common rows। |
| MINUS/EXCEPT | पहले में से दूसरे को घटाओ। Non-commutative। |
| Subquery | Inner query पहले run। Outer query को result देती है। |
| Index | Read fast, Write slow। Extra storage। |
| B+ Tree | Range queries, ORDER BY। O(log N)। |
| Hash | Exact match। O(1)। Range नहीं। |
| Atomicity | Transaction दौरान failure → Rollback। All or Nothing। |
| Durability | Commit के बाद crash → Data safe। Disk पर permanent। |
| Isolation | Concurrent transactions interfere नहीं करते। |
| Dirty Read | Uncommitted data पढ़ना → Isolation violation। |
| Cascading Rollback | Dirty Read → एक fail → सब fail। Cascadeless से बचाव। |
| Generalization | Bottom-Up। कई entities → एक। ISA triangle। |
| Specialization | Top-Down। एक entity → कई। ISA triangle। |
| Aggregation | Relationship → Entity। Dashed rectangle। |
| Weak Entity | No Primary Key। Depends on Strong entity। Double rectangle। |
| Schema | DB की logical structure। Instance = actual data at a time। |
| NoSQL | "Not Only SQL"। Schema-free। Big Data। 4 types। |
| MongoDB | Document DB। C++ में written। Collection=Table, Document=Row। |
| Sharding | एक DB को rows में split। Homogeneous। Autonomy खोना। |
| Federation | कई DBs → एक window। Heterogeneous। Autonomy बनाए रखना। |
| SQL Execution Order | FROM→WHERE→GROUP BY→HAVING→SELECT→ORDER BY |
| Alias in WHERE | SELECT alias को WHERE में use नहीं कर सकते (execution order)। |
🧠 All Memory Tricks — एक जगह
Codd vs Chen: C for Codd = C for Columns/Relational (1970). Chen = ER = Entity Relationship (1976). B for Bachman = B for Beginning (1st DBMS).
Execution Order (Fw Gh So): FROM → WHERE → GROUP BY → HAVING → SELECT → ORDER BY
ACID: A=Atomic(All/Nothing), C=Consistency(Valid), I=Isolated(No disturbance), D=Disk(Durable after commit)
Keys: Primary = ONE per table, Perfect (No NULL). Unique = U = 1 NULL allowed. Foreign = Foreign table की PK।
H before N: Hierarchical (oldest, 1960s) → Network → Relational. "H comes before N in alphabet"
DDL = Design, DML = Data, DCL = Cops (Security), TCL = Time-management
JOIN Selection: "all records regardless / even if doesn't exist" → LEFT JOIN। m×n = CROSS JOIN।
Diamond ♦ = Relationship (diamond ring connects two). Rectangle = Entity. Ellipse = Attribute.
ANY = at least one (OR), ALL = every single one (AND). "ALL" से बड़ा = MAX से भी बड़ा।
Index = Read Fast, Write Slow (किताब के पीछे index से पन्ना ढूंढना fast; बीच में नया पन्ना जोड़ना slow)
NoSQL Types D-K-C-G: Document, Key-value, Column, Graph
Cascading = Waterfall: ऊपर गिरा तो नीचे सब गिरे। बचाव = Dirty Read मत करो।
Federation = Freedom (हर DB अपना boss) | Sharding = Shredding (rows में काट दो)
Attribute = Column, Tuple = Row: A-ttribute = A column। T-uple = T-able row।
WHERE=Worker(Row-level), HAVING=Head(Group-level). W comes before H alphabetically।
NOT IN vs NOT EXISTS: NOT IN + NULL = empty result। NOT EXISTS = safer with NULLs।
🗄️ DBMS Master Revision Handbook | 467 MCQs Analyzed | 18 Answer Key Bugs Fixed | Rajasthan Exam Ready
Rajasthan Exam Twister
Comprehensive Preparation for Rajasthan Exams
Review detailed blog breakdowns, previous year papers, and topical revision handbooks.