Database Tutorial #18: Database Design Patterns

Good schema design is not about theory. It is about patterns that solve real problems — audit trails, multi-tenancy, concurrent updates, and data history. These patterns work with any relational database. Soft Deletes Hard deleting rows permanently removes data. Soft deletes mark rows as deleted without removing them — useful for audit trails, undo functionality, and regulatory compliance. ALTER TABLE users ADD COLUMN deleted_at TIMESTAMPTZ; -- Soft delete UPDATE users SET deleted_at = NOW() WHERE id = 42; -- Query active users only SELECT * FROM users WHERE deleted_at IS NULL; -- Include deleted users SELECT * FROM users; -- Restore UPDATE users SET deleted_at = NULL WHERE id = 42; Create a partial index for performance on active records: ...

August 8, 2026 · 5 min

Database Tutorial #7: PostgreSQL Migrations and Schema Design

Your schema is the foundation of everything. Bad schema decisions are expensive to fix later. Good ones make your application easier to build and scale. Why Migrations? A migration is a versioned SQL file that changes your schema. Instead of running ALTER TABLE manually in production and hoping everyone does the same, migrations track every schema change in version control. Every team member applies the same migrations in the same order. Your CI pipeline applies them automatically. Rollbacks are possible. ...

August 5, 2026 · 6 min