RAPID EXAM REFERENCE · 1-PAGE SUMMARIES

Database Management Systems Cheat Sheets

One page per topic for when you have 10 minutes before an exam: the core rule, the formulas, and the traps.

Database Architecture & The Three-Schema Framework

Why DBMS Exists: File Systems vs DBMS & The Three-Schema Architecture

Open Full Lesson →

Three-Schema Levels: External (Views) → Conceptual (Logical Schema) → Internal (Physical Storage). Physical data independence insulates conceptual tables from storage layout; Logical data independence insulates views from schema evolution.

Must-Remember Principles:
  • —Physical Data Independence: Alter index, file layout, block format without touching conceptual schema.
  • —Logical Data Independence: Add table, split columns without breaking existing views.
  • —DDL defines conceptual tables; DSDL defines storage; DML queries data; DCL manages permissions; TCL manages transactions.
Critical Pitfalls & Exam Traps:
  • ×Physical data independence is much easier to achieve and maintain than logical data independence.
  • ×File systems manage bytes and files; DBMS engines manage typed relations, constraints, and ACID transactions.
Entity-Relationship & Relational Schema Mapping

ER & Extended ER Modeling: Constraints, Weak Entities & Minimum Tables

Open Full Lesson →

Weak Entity Key = Identifying Owner PK + Discriminator. M:N requires 3 tables; 1:N with total participation on N-side requires 2 tables; 1:1 with total participation on both sides requires 1 table.

Must-Remember Principles:
  • —M:N relationship → strictly 3 tables.
  • —1:N relationship with total on N-side → 2 tables (merge relationship into N-side table).
  • —1:1 relationship with total on both sides → 1 table.
  • —Weak entity + identifying owner → 2 tables (weak entity table absorbs identifying relationship).
  • —Multivalued attribute → separate table containing {Owner PK, Attribute}.
Critical Pitfalls & Exam Traps:
  • ×Multivalued attributes ALWAYS require their own separate table with foreign key to owner.
  • ×A partial key (discriminator) cannot identify a tuple across the database by itself without the owner entity's primary key.
Relational Model, Relational Algebra & Calculus

Relational Algebra, Tuple Calculus & The Division Operator

Open Full Lesson →

Selection filters rows; Projection extracts columns; Cartesian Product multiplies cardinalities; Division answers FOR ALL universal quantification queries.

Must-Remember Principles:
  • —deg(R × S) = deg(R) + deg(S); card(R × S) = |R| × |S|.
  • —Natural Join R(m) ⋈ S(n) with FK = exactly m tuples.
  • —General Natural Join R(m) ⋈ S(n) bounds = [0, m × n].
  • —Division R(A, B) ÷ S(B) yields tuples in A associated with EVERY tuple in S.
  • —Set Difference R - S requires union compatibility (identical arity and compatible domains).
Critical Pitfalls & Exam Traps:
  • ×Projection removes duplicates in pure relational algebra; SQL SELECT does NOT unless DISTINCT is specified.
  • ×Natural join on disjoint sets of common attribute values yields an empty relation.
SQL Mastery, 3-Valued Logic & Complex Subqueries

SQL Mastery: 3-Valued Logic, Aggregates & Correlated Subqueries

Open Full Lesson →

WHERE requires TRUE to keep rows; UNKNOWN and FALSE are both discarded. Comparison with NULL (col = NULL) evaluates to UNKNOWN. COUNT(*) counts all rows; COUNT(col) counts only non-NULL entries.

Must-Remember Principles:
  • —NOT IN with any NULL in subquery returns 0 rows! Always prefer NOT EXISTS.
  • —COUNT(*) counts all rows; COUNT(col) counts only non-null values.
  • —Execution order: FROM → WHERE → GROUP BY → HAVING → SELECT → ORDER BY.
  • —WHERE filters raw rows; HAVING filters grouped aggregates.
  • —3-Valued Logic truth tables: NULL OR TRUE = TRUE; NULL AND FALSE = FALSE; NULL OR FALSE = UNKNOWN.
Critical Pitfalls & Exam Traps:
  • ×Never write WHERE col = NULL; write WHERE col IS NULL.
  • ×Column aliases created in SELECT cannot be referenced in WHERE.
Functional Dependencies & Normalization (1NF to BCNF)

Functional Dependencies, Candidate Keys & Normal Forms (1NF to BCNF)

Open Full Lesson →

2NF = No Partial Dependency (prime subset -> non-prime). 3NF = For all X -> Y, X is Superkey OR Y is Prime. BCNF = For all X -> Y, X MUST be a Superkey.

Must-Remember Principles:
  • —Superkey count with single key size k: 2^(n - k).
  • —Lossless Decomposition Condition: (R1 ∩ R2) → R1 or (R1 ∩ R2) → R2.
  • —3NF always guarantees dependency preservation; BCNF may lose dependencies.
  • —Attributes that never appear on the RHS of any FD MUST be in every candidate key.
  • —Armstrong's Axioms: Reflexivity (Y ⊆ X ⇒ X → Y), Augmentation (X → Y ⇒ XZ → YZ), Transitivity (X → Y ∧ Y → Z ⇒ X → Z).
Critical Pitfalls & Exam Traps:
  • ×A partial dependency only exists when a PROPER SUBSET of a candidate key determines a non-prime attribute.
  • ×If all candidate keys are single attributes, 2NF is automatically satisfied without checking!
Storage, Indexing & B/B+ Trees

B & B+ Trees, Multi-Level Indexing & Disk I/O Arithmetic

Open Full Lesson →

B+ Tree: Keys only in internal nodes; keys + data pointers in leaves; leaves linked horizontally. Internal order: p · Pb + (p - 1) · K ≤ B. Leaf order: m · (K + Pr) + Pb ≤ B.

Must-Remember Principles:
  • —Internal order inequality: p · Pb + (p - 1) · K ≤ B.
  • —Leaf order inequality: m · (K + Pr) + Pb ≤ B.
  • —Min keys non-root internal: ⌈p/2⌉ - 1. Min keys non-root leaf: ⌈m/2⌉.
  • —Root min keys: 1 key (2 pointers). Max keys: p - 1.
  • —Disk I/Os for search = Height + 1 (Height index blocks + 1 data block).
Critical Pitfalls & Exam Traps:
  • ×In internal nodes, pointers are p and keys are p - 1; in leaf nodes, pointers and keys are both m (plus 1 next block pointer).
  • ×Range queries in B+ Trees do not traverse back up to the root; they walk horizontally along the leaf pointers.
Transactions & Concurrency Control

ACID Invariants, Precedence Graphs & Conflict Serializability

Open Full Lesson →

Conflicting pair = Same data item, different transactions, AT LEAST ONE WRITE. A schedule is Conflict Serializable iff its directed Precedence Graph is ACYCLIC.

Must-Remember Principles:
  • —Precedence Graph: Edge Ti → Tj exists if Ti executes an operation that conflicts with a subsequent operation of Tj.
  • —Acyclic precedence graph? Topological sort gives equivalent serial schedule!
  • —Recoverable: Ti commits before Tj commits (where Tj reads a value written by Ti).
  • —Cascadeless: Ti commits before Tj READS the value written by Ti.
  • —Strict: Ti commits before Tj reads OR writes the item written by Ti.
Critical Pitfalls & Exam Traps:
  • ×Two READ operations on the same data item never conflict with each other.
  • ×A schedule can be conflict serializable but still non-recoverable! Serializability and Recoverability are independent dimensions.
Concurrency Protocols, Deadlocks & Crash Recovery

Two-Phase Locking (2PL), Timestamp Ordering & Write-Ahead Logging

Open Full Lesson →

Strict 2PL holds exclusive write locks until transaction commit (guarantees cascadelessness). Conservative 2PL acquires all locks prior to execution (deadlock-free). Write-Ahead Logging (WAL) flushes log records before dirty buffer pages.

Must-Remember Principles:
  • —Basic 2PL: Growing phase (acquire locks only) -> Shrinking phase (release locks only). Guarantees conflict serializability.
  • —Strict 2PL: Holds exclusive locks until commit. Guarantees conflict serializability + strict recoverability. Still prone to deadlocks.
  • —Rigorous 2PL: Holds ALL locks (shared and exclusive) until commit.
  • —Wait-Die (Non-preemptive): Old waits for Young; Young dies if requesting lock held by Old.
  • —Wound-Wait (Preemptive): Old wounds Young (preempts lock); Young waits for Old.
  • —Crash Recovery (WAL): Committed before crash? REDO using log after-image. Uncommitted before crash? UNDO using log before-image.
Critical Pitfalls & Exam Traps:
  • ×Deadlocks can still occur in Strict 2PL and Rigorous 2PL!
  • ×Redo requires the log's AFTER-image; Undo requires the log's BEFORE-image.
Data Warehousing & Multidimensional Modeling

Data Warehousing, Multidimensional OLAP Models & Star/Snowflake Schemas

Open Full Lesson →

Data Warehouses separate analytical OLAP workloads from transactional OLTP. Fact tables hold numeric additive measures; Dimension tables hold descriptive hierarchies. Star schema denormalizes dimensions; Snowflake schema normalizes dimensions into BCNF/3NF.

Must-Remember Principles:
  • —OLTP vs OLAP: OLTP is write-heavy, 3NF/BCNF normalized, row-oriented, ACID transactional. OLAP is read-heavy, star/snowflake denormalized, column-oriented, analytical aggregate queries.
  • —Fact Table: Contains composite primary key (concatenation of foreign keys to all dimension tables) and numerical measures (additive e.g. sales, semi-additive e.g. bank balance, non-additive e.g. unit price/ratios).
  • —Star Schema: Single central fact table directly referencing completely denormalized, un-normalized dimension tables (simple queries, fast joins, higher data redundancy).
  • —Snowflake Schema: Dimension tables are normalized into sub-dimension hierarchies (e.g., Item -> Brand -> Category). Reduces redundancy, but requires multi-table joins.
  • —Fact Constellation (Galaxy Schema): Multiple fact tables sharing common conformed dimension tables (e.g., Sales Fact and Shipping Fact sharing Date and Store dimensions).
  • —OLAP Operations: (1) Roll-up (aggregation/climbing hierarchy e.g. day -> month), (2) Drill-down (disaggregation/descending hierarchy e.g. quarter -> month), (3) Slice (fixing one dimension e.g. Time = '2024'), (4) Dice (sub-cube selection along multiple dimensions), (5) Pivot (rotating cube axes).
  • —OLAP Architectures: ROLAP (Relational OLAP, star schemas in RDBMS), MOLAP (Multidimensional OLAP, pre-computed dense arrays/tensors), HOLAP (Hybrid OLAP, detailed data in ROLAP, aggregated summaries in MOLAP).
Critical Pitfalls & Exam Traps:
  • ×A measure cannot be added across dimensions if it is non-additive (e.g., averaging percentages or profit margins across stores requires recomputing numerator and denominator).
  • ×Snowflake schema reduces storage redundancy compared to Star schema, but degrades query performance due to additional JOIN operations.
Data Warehousing & Multidimensional Modeling

Data Transformations: Normalization, Discretization, Sampling & Compression

Open Full Lesson →

Fit transformations using training data only, preserve the target meaning, and state which information the transformation discards.

Must-Remember Principles:
  • —Min-max to [a,b]: x' = a + (x - min)(b - a)/(max - min), when max > min.
  • —Z-score: x' = (x - μ)/σ; specify population or sample estimates and define the zero-variance case.
  • —Equal-width discretization divides a numeric interval into bins of equal width; equal-frequency discretization targets similar counts per bin.
  • —Compression ratio = original size / compressed size; lossy methods trade exact reconstruction for size.
Critical Pitfalls & Exam Traps:
  • ×For a constant feature, min=max; the formula is undefined and needs an explicit policy.
  • ×Compute scaling parameters on training data, not on the full data before a train/test split.
  • ×Database normalization into 1NF/2NF/3NF is a different meaning from numerical feature scaling.
  • ×Sampling with replacement and without replacement have different probabilities; state the design.