SynfraCore
Synfracore
Start Learning
Navigation

Academies

Platform

RoadmapsLabsCertificationsInterviewPYQsAI AssistantCareer
Start Learning Free🗺️ Learning Roadmaps

Database DesignCheatsheets

Quick reference — commands, syntax, and patterns

✍️
Written by senior engineers. Reviewed for technical accuracy.· Updated 2025 · SynfraCore Database Design Team
Expert Content

Database Design — Quick Reference

Normal forms, quick reference

FormRuleFixes

|---|---|---|

1NFAtomic values, no repeating groupsArrays/lists crammed into one column
2NF1NF + no partial dependenciesColumns dependent on only part of a composite key
3NF2NF + no transitive dependenciesColumns dependent on a non-key column, not the key directly
BCNFStronger 3NFEvery determinant is a candidate key

Constraint syntax quick reference

sql
-- NOT NULL + foreign key
customer_id INT NOT NULL REFERENCES customers(id) ON DELETE RESTRICT

-- CHECK constraint
status VARCHAR(20) CHECK (status IN ('pending','shipped','delivered'))

-- Composite unique constraint
CONSTRAINT unique_customer_order UNIQUE (customer_id, order_id)

-- Partial unique index (workaround for NULL-handling in UNIQUE, see Troubleshooting)
CREATE UNIQUE INDEX idx_unique_active_email ON users(email) WHERE deleted_at IS NULL;

Index types, quick reference

TypeUse case

|---|---|

B-Tree (default)Equality and range queries
CompositeMulti-column filters — leading column should be highest-selectivity equality condition
PartialIndex only a subset of rows (WHERE status = 'active') — smaller, faster for that specific query
Covering (INCLUDE)Avoids a table lookup by including extra columns the query needs, directly in the index
GINJSONB, array, full-text search columns

`EXPLAIN ANALYZE` — what to look for

sql
EXPLAIN ANALYZE SELECT * FROM orders WHERE customer_id = 1;
Plan nodeMeaning

|---|---|

`Seq Scan`Full table scan — fine for small tables/large result fractions, a red flag otherwise
Index ScanUsing an index directly
Index Only ScanIndex alone satisfies the query, no table lookup needed (covering index)
Bitmap Heap ScanIndex used to build a bitmap of matching rows first, then fetched

CAP theorem, quick reference

SystemCP or AP

|---|---|

PostgreSQL, MySQLCP
MongoDBCP (default config)
Cassandra, DynamoDBAP
CouchDBAP

Multi-tenant isolation strategies, quick comparison

ApproachIsolationOperational cost

|---|---|---|

Shared table + `tenant_id`Weakest (relies on scoping discipline/RLS)Lowest
Schema-per-tenantStrongerMedium — migrations across many schemas
Database-per-tenantStrongestHighest

Partitioning types, quick reference

TypeBest for

|---|---|

RangeTime-series data (date-based)
ListDiscrete categories (region, tenant)
HashEven distribution, no natural range/list key
Share:
Join our Community
Daily tips, job alerts, interview help — join engineers learning together
Also Worth Exploring
← Back to all Database Design modules
CertificationNotes