Relational Database Design
Relational database design turns business facts into related tables, keys, and rules. It helps you store each fact in a clear place and prevent invalid or contradictory relationships.
itDatabases and data storage | OpenSkills.info
Course pathWalk it in order
Look it upDip in anytime
Go furtherLeaves this page
Don't Panic
Don't Panic: Relational Database Design
A relational database design is the part where ordinary business facts are persuaded to stop wandering around in columns and acquire an address. It decides what a row means, which facts belong together, and which combinations the database must reject. The table is only the visible furniture. The contract is the building.
Begin with grain, meaning the exact fact represented by one row. An order row is one order. An order-line row is one product on one order. This sounds modest until a product name, an order date, and a quantity all queue up asking for a home. Grain answers them before they form a small but determined committee in the wrong table.
Next come relationships and keys. A customer can have orders, an order can have lines, and a product can appear in many lines. The order-line table is not bureaucratic paperwork. It is where the relationship lives, along with facts such as quantity and agreed price. A primary key identifies a row; a foreign key says which related rows are permitted. A generated identifier can help with references, but it cannot magically make a duplicated product code unique.
Then make the important rules executable. NOT NULL, UNIQUE, foreign keys, and checks are the database's way of declining bad data with considerably more consistency than a diagram. Normalization helps place each fact with the key that determines it, so repeated copies do not develop independent opinions about a product name. It is not a contest to build the most tables. It is a way to find redundancy before redundancy finds production.
Physical choices arrive later, wearing more expensive shoes. Indexes can speed selected lookups, but also add storage and write work. Denormalization can serve a measured read need, but it needs a source of truth, a maintenance rule, and a repair path. A duplicate without those is not performance engineering. It is a future reconciliation task hiding under a useful-looking name.
Read the Intro for the full path from domain terms to constraints. Use Slides when the relationships and dependency questions need a compact map. Keep the Cheatsheet nearby when reviewing keys, normal forms, indexes, and failure signals. The Practice tab turns the ideas into a purchase-order schema, where invalid inserts have the useful habit of telling you exactly which rule you forgot to declare.
Where this skill leads
Relevant careers
See how this topic contributes to broader role-level skill maps.
Sources
- https://research.ibm.com/publications/a-relational-model-of-data-for-large-shared-data-banks
Supports
- The relational model is based on n-ary relations and addresses data representation independence
- Normalization and redundancy-consistency problems are core relational-model concerns
- Codd published the relational model in 1970
- https://www.postgresql.org/docs/current/ddl-constraints.html
Supports
- NOT NULL, UNIQUE, PRIMARY KEY, FOREIGN KEY, and CHECK constraints have distinct roles
- A primary key is unique and not null
- Foreign keys preserve referential integrity by requiring matches in a referenced table
- Composite foreign keys and unique constraints can cover multiple columns
- CHECK constraints are row-oriented and should not be used for arbitrary cross-row guarantees
- Foreign-key actions are part of a declared relationship contract
- https://learn.microsoft.com/en-us/office/troubleshoot/access/database-normalization-description
Supports
- Normalization reduces redundancy and inconsistent dependencies
- First normal form removes repeating groups and uses primary keys
- Second normal form separates facts that do not depend on the complete key
- Third normal form removes fields that do not depend on the key
- Normalization can require additional tables and needs practical judgment
- https://www.postgresql.org/docs/current/indexes.html
Supports
- Indexes can accelerate row retrieval
- Indexes add system overhead and should be used deliberately
- https://dev.mysql.com/doc/workbench/en/wb-design-modeling-interface.html
Supports
- MySQL Workbench provides model editing, EER diagrams, table creation, and foreign-key relationship creation
- Existing schemas can be reverse engineered into a model
- https://github.com/mgramin/awesome-db-tools
Supports
- The curated list includes dbdiagram.io under database-design tools
- The curated list includes pgModeler under database-design tools
- The curated list includes Atlas under schema migration tools
- https://www.postgresql.org/docs/current/sql-createtable.html
Supports
- CREATE TABLE supports column and table constraints including primary keys, foreign keys, unique constraints, checks, and referential actions
- A purchase-order schema can demonstrate valid and rejected relational states through DDL and inserts
- https://doi.org/10.1145/320434.320440
Supports
- Peter Chen published the entity-relationship model in 1976
- The entity-relationship model uses entities, relationships, and diagrams for database design
- https://dev.mysql.com/doc/refman/8.0/en/compatibility.html
Supports
- The SQL standard has evolved since 1986
- SQL-92, SQL:1999, SQL:2003, SQL:2008, and SQL:2011 are dated SQL standard revisions
- https://docs.dbdiagram.io/
Supports
- dbdiagram.io uses DBML to create entity-relationship diagrams
- dbdiagram.io offers free and paid plans
- https://pgmodeler.io/
Supports
- pgModeler is a PostgreSQL schema-engineering tool with community and commercial editions
- pgModeler supports visual design, reverse engineering, diffing, synchronization, and CLI automation
- https://dashboard.sqldbm.com/Pricing/
Supports
- SqlDBM provides data-model management and paid support options
- https://docs.oracle.com/database/sql-developer-17.3/DMDUG/data-modeler-preface.htm
Supports
- Oracle SQL Developer Data Modeler is a data modeling and database design environment
- https://dbmodeler.io/
Supports
- DBModeler supports visual ER modeling and SQL generation for multiple database engines
