CtrlK
BlogDocsLog inGet started
Tessl Logo

jbvc/database-design

Database design principles and decision-making. Schema design, indexing strategy, ORM selection, serverless databases.

62

Quality

62%

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

schema-design.md

Schema Design Principles

Normalization, primary keys, timestamps, relationships.

Normalization Decision

When to normalize (separate tables):
├── Data is repeated across rows
├── Updates would need multiple changes
├── Relationships are clear
└── Query patterns benefit

When to denormalize (embed/duplicate):
├── Read performance critical
├── Data rarely changes
├── Always fetched together
└── Simpler queries needed

Primary Key Selection

TypeUse When
UUIDDistributed systems, security
ULIDUUID + sortable by time
Auto-incrementSimple apps, single database
Natural keyRarely (business meaning)

Timestamp Strategy

For every table:
├── created_at → When created
├── updated_at → Last modified
└── deleted_at → Soft delete (if needed)

Use TIMESTAMPTZ (with timezone) not TIMESTAMP

Relationship Types

TypeWhenImplementation
One-to-OneExtension dataSeparate table with FK
One-to-ManyParent-childrenFK on child table
Many-to-ManyBoth sides have manyJunction table

Foreign Key ON DELETE

├── CASCADE → Delete children with parent
├── SET NULL → Children become orphans
├── RESTRICT → Prevent delete if children exist
└── SET DEFAULT → Children get default value

database-selection.md

indexing.md

migrations.md

optimization.md

orm-selection.md

schema-design.md

SKILL.md

tile.json