Part 150: The SQL Master Blueprint: 25 Principal Database Rules

Part 150 Technology Updated September 12, 2026

Part 150: The SQL Master Blueprint: 25 Principal Database Rules

Congratulations on reaching the final part of this comprehensive 150-Part SQL Language Tutorial series! In this capstone, we synthesize our entire curriculum into 25 core rules for principal-level database engineering.


The 25 Golden Rules of Relational Database Engineering

  1. Explicit Columns: Never use SELECT * in production queries.
  2. Surrogate Keys with Business UUIDs: Pair internal auto-increment primary keys with exposed UUIDs.
  3. Always Index Foreign Keys: Prevents full table locks on cascading updates and joins.
  4. Enforce Referential Integrity: Use foreign key constraints rather than hoping application code maintains relations.
  5. Decimals for Money: Never use FLOAT or DOUBLE for financial amounts.
  6. UTC Everywhere: Store audit timestamps as TIMESTAMPTZ in UTC.
  7. Explicit Nullability: Declare NOT NULL by default on all columns.
  8. Keyset Pagination over Offset: Use WHERE id < :last_id for scalable pagination.
  9. Beware the NOT IN + NULL Trap: Use NOT EXISTS instead of NOT IN.
  10. Parentheses for Logic: Wrap mixed AND and OR conditions in explicit parentheses.
  11. UNION ALL by Default: Use UNION ALL unless duplicate removal is strictly required.
  12. CTEs for Readability: Replace deeply nested subqueries with structured CTEs.
  13. Keep Window Functions in Select: Leverage OVER (PARTITION BY ...) for analytical reporting without row collapse.
  14. Avoid Leading Wildcards: LIKE '%query' cannot use standard B-Tree indexes.
  15. SARGable Filters: Never wrap indexed columns in functions inside WHERE clauses.
  16. Profile with EXPLAIN ANALYZE: Verify execution plans before guessing optimizations.
  17. Covering Indexes for Hot Paths: Use INCLUDE columns to enable Index-Only Scans.
  18. Normalize to 3NF First: Normalize for integrity, and denormalize only after profiling proven bottlenecks.
  19. Drop Unused Indexes: Eliminate indexes with 0 scans to restore write performance.
  20. Keep Transactions Short: Minimize lock holding times and lock escalation risks.
  21. Deterministic Lock Ordering: Acquire locks in alphabetical/ID order to prevent deadlocks.
  22. Always Parameterize Queries: Defeat SQL Injection 100% of the time.
  23. Partition Massive Datasets: Use declarative range partitioning on time-series logs.
  24. Multi-Tenant Row-Level Security: Enforce tenant data isolation with database RLS policies.
  25. Automate Continuous Backups: Verify Point-in-Time Recovery (PITR) procedures regularly.

Conclusion

You have mastered SQL from foundational DQL to advanced analytical window functions, internal engine architecture, indexing mechanics, and enterprise database administration. May your queries run in milliseconds!