All cheat sheets
🗄️

DBMS & SQL

Keys, normal forms, transactions, indexes, and must-know SQL patterns.

Keys & Design

Primary keyUnique + not null identifier for a row.
Foreign keyReferences primary key of another table (referential integrity).
1NF / 2NF / 3NFAtomic cols → no partial dep → no transitive dep on PK.
BCNFStronger 3NF: every determinant is a candidate key.

Transactions (ACID)

AtomicityAll or nothing — no partial commits.
ConsistencyDB moves from one valid state to another.
IsolationConcurrent txns don't step on each other (levels: RU→S).
DurabilityCommitted data survives crashes (WAL/logs).

SQL Patterns

JOIN typesINNER, LEFT, RIGHT, FULL — match rows across tables.
GROUP BYAggregate per group; HAVING filters groups.
Window fnROW_NUMBER, RANK, SUM() OVER (PARTITION BY …).
IndexSpeeds lookups; B+ tree common; write cost + storage trade-off.