Schema design choices propagate through the entire application lifetime. OLTP schemas favour normalisation (3NF) to minimise write anomalies and storage. OLAP/data warehouse schemas denormalise into star or snowflake schemas to minimise joins at query time. Temporal tables track historical changes with system-period versioning. Soft deletes (deleted_at timestamp) preserve audit history. Surrogate keys (UUID/serial) decouple application from natural key changes.
System-period temporal tables for audit history.
Sequential integers expose total count and enable enumeration attacks. UUID v4 (random) or UUIDv7 (time-ordered, better for index locality) are standard for API-exposed identifiers.
WHERE deleted_at IS NULL filters must use partial indexes: CREATE INDEX ON users(email) WHERE deleted_at IS NULL. A full index including deleted rows wastes space and slows queries.
Once a migration runs in any environment, it is immutable. Edit = checksums fail in Flyway, or drift between environments. Always add new migrations instead of modifying existing ones.
Sign in to share your feedback and join the discussion.