All cheat sheets
🗄️
DBMS & SQL
Keys, normal forms, transactions, indexes, and must-know SQL patterns.
Keys & Design
| Primary key | Unique + not null identifier for a row. |
|---|---|
| Foreign key | References primary key of another table (referential integrity). |
| 1NF / 2NF / 3NF | Atomic cols → no partial dep → no transitive dep on PK. |
| BCNF | Stronger 3NF: every determinant is a candidate key. |
Transactions (ACID)
| Atomicity | All or nothing — no partial commits. |
|---|---|
| Consistency | DB moves from one valid state to another. |
| Isolation | Concurrent txns don't step on each other (levels: RU→S). |
| Durability | Committed data survives crashes (WAL/logs). |
SQL Patterns
| JOIN types | INNER, LEFT, RIGHT, FULL — match rows across tables. |
|---|---|
| GROUP BY | Aggregate per group; HAVING filters groups. |
| Window fn | ROW_NUMBER, RANK, SUM() OVER (PARTITION BY …). |
| Index | Speeds lookups; B+ tree common; write cost + storage trade-off. |