Designing a database from scratch starts with a written model of what the system must remember and how those facts relate, and only then becomes tables, keys, and indexes. Model first, choose the engine second, index last. That order matters because most database pain in production — duplicated values, orphaned rows, slow reports — traces back to decisions made before anyone wrote CREATE TABLE. This guide walks through the full sequence: requirements, conceptual model, logical design, engine choice, physical schema, constraints, indexing, migrations, sample data, and rollout. It assumes a relational core, which is still the safest default for transactional business data, while noting where document and key-value stores genuinely fit better.

Step 1: Define what the database must remember and answer

Before any modeling, write down the questions the application must answer and the facts it must retain. Do this in plain language. "A customer can place many orders, each order has line items, each line item references one product" is a sentence you can later turn into tables; "users table with order info" is a decision smuggled in without justification.

Separate three things:

Entities and their attributes. The nouns you store: customers, products, invoices, sensor readings. Queries. The questions the system must answer: "Which invoices are overdue?", "What did this customer buy last quarter?", "How many units of this SKU shipped yesterday?" Scale and access shape. Rough row counts, read-versus-write ratio, whether the dominant access is by primary key, by time window, or by a search pattern.

Get numbers, even rough ones. A system with 50,000 rows and a system with 500 million rows permit different designs. Write the estimates down — growth per month, expected peak write rate, retention period — and label them as estimates. These numbers drive every later trade-off, from index choices to whether a single database even fits.

A useful deliverable here is a one-page data dictionary in prose or a spreadsheet: entity, attribute, type, whether it is required, and any rule ("email must be unique per account", "an order cannot be deleted, only cancelled"). Share it with whoever owns the business rules. Ambiguity caught now costs minutes; ambiguity caught after launch costs migrations.

Check: every query in your list should be answerable from the entities you have named, or you have found a missing entity. If a query cannot be answered without scraping text out of a free-form notes field, that field is hiding a structure you have not modeled yet.

Step 2: Draw the conceptual model and identify relationships

Now turn the entity list into a diagram. You do not need formal notation, but an entity-relationship (ER) diagram — boxes for entities, lines for relationships, labels for cardinality — forces every assumption into view. This step is about meaning, not storage. Called the conceptual model, it should describe the business domain independently of any specific database product.

For each relationship, pin down the cardinality precisely:

One-to-many. One order has many line items; each line item belongs to exactly one order. Many-to-many. Students enroll in many courses; courses have many students. Relational design resolves this with a join table, often with its own attributes such as enrollment date or grade. One-to-one. A user has one profile. Often worth merging into a single table unless separation serves a purpose like access control or large optional fields. Optionality. Can an order exist without a customer? Can an order line exist before the product is assigned? Optionality determines whether later foreign keys are nullable, which is a policy decision, not a technicality.

Watch for the classic modeling traps. A repeated group stuffed into one column ("phone1, phone2, phone3") means you really have a separate phones table. A product's price copied onto every line item is usually intentional — it captures the price at the time of sale — but you should be able to explain why. And attributes that depend on a combination of things rather than a single thing signal a normalization issue coming up in Step 3.

Check: read each relationship aloud as a sentence with its cardinality ("Each customer places zero or more orders; each order belongs to exactly one customer"). If any sentence sounds wrong to the domain expert, the diagram is wrong.

Step 3: Normalize the logical model, then selectively denormalize

Normalization is the discipline of eliminating redundancy and update anomalies. The first three normal forms cover most practical work:

First normal form (1NF): each column holds one atomic value per row, no repeating groups. Second normal form (2NF): no non-key attribute depends on only part of a composite key. Third normal form (3NF): no non-key attribute depends on another non-key attribute — dependencies live only on keys.

A concrete example makes 3NF tangible. Suppose an orders table includes customer_email. That email depends functionally on customer_id, not on order_id. Change the customer's email and you must update every historical order row or accept inconsistency. Normalizing moves email into customers, keeping a single source of truth.

Normalization has real costs: more tables means more joins, and very wide analytical queries can become slow. That is why mature designs denormalize deliberately in specific places. Denormalize when you can name the read pattern it serves and the synchronization rule that keeps the copy correct (for example, storing order_total on the order header, updated in the same transaction as line-item changes, because totals are read constantly and recomputed rarely). What you should not do is denormalize by accident, with copies maintained in application code across three services and no owner.

Check: for every duplicated fact, write down where the authoritative version lives and what updates the copy. If either answer is "nowhere" or "the app, I think," the design is not finished.

Step 4: Choose the database engine for the access pattern

The conceptual and logical models are mostly engine-neutral. Choosing the product is where the access pattern from Step 1 comes back. The main families:

Family Best fit Watch out for
Relational (SQL) Transactions, multi-entity integrity, ad hoc reporting Schema migrations require care at scale
Document Semi-structured, evolving per-record shapes, app-centric reads Cross-document consistency, join-like queries
Key-value Very high-throughput simple lookups, caching, sessions No query flexibility beyond the key
Wide-column Massive write volumes, time-series-like access Query patterns must be known in advance
Search engine Full-text and relevance-ranked retrieval Not a system of record without care

The honest default for business systems that need correctness across entities — money, orders, inventory, permissions — is a relational database, because the engine enforces integrity rather than trusting every code path. Document stores shine where records genuinely differ in shape and the app mostly reads them whole by key. Key-value stores are excellent as a deliberate complement to a relational core, not usually as a replacement for it.

Pick one primary system of record and write that sentence down. Mixed polyglot architectures are legitimate, but each additional store adds a synchronization problem. If you cannot describe how the two stores reconcile after a partial failure, you have added risk without a plan for it.

Check: confirm your chosen engine supports the query shapes from Step 1 without application-side gymnastics. If your key queries require exporting data to another system to answer, reconsider the engine.

Step 5: Translate the model into a physical schema

Now write the actual schema. For a relational design, each entity becomes a table, each attribute a column with a concrete type, and each relationship a foreign key. Use the engine's native types rather than generic ones: store money as fixed-precision decimal (or integer minor units), timestamps with an explicit time zone convention (typically UTC in storage, local at display), and booleans as booleans.

Define identifiers deliberately. An auto-incrementing integer is simple and compact; a UUID avoids coordination across independent writers and simplifies merges, at the cost of larger indexes and, with random UUIDs, worse index locality. Whichever you pick, commit to it everywhere — mixed identifier strategies are a long-term tax.

Then encode the rules from Step 1 as constraints:

NOT NULL for required facts. This is the cheapest enforcement you get. UNIQUE for natural identifiers such as email per account or SKU. FOREIGN KEY to prevent orphaned rows. Referential integrity is one of the strongest reasons to choose a relational core. CHECK for value rules — quantity greater than zero, status in a known set — so invalid data fails at insert time rather than in a report six months later.

Sketching the schema:

This is illustrative syntax, not a specific product's dialect; the exact type names and constraint syntax vary by engine, so confirm them in that engine's documentation.

Check: attempt a few invalid inserts by hand — an order with no customer, a negative quantity, a duplicate email. If the database rejects them, the constraints are doing their job. If the application must catch them, you have a gap.

Step 6: Index for your real read patterns

Indexes speed up reads and slow down writes, so they should follow the queries from Step 1, not cover every column hopefully. The primary key is indexed automatically. Beyond that:

Foreign keys usually need indexes on the referencing side. Many engines do not create them automatically, and without one, deleting a parent row or joining children can scan the whole child table. Frequent equality lookups — find order by customer, find user by email — justify an index. A unique constraint often provides it for free. Range and sort patterns — "orders in the last 30 days, newest first" — benefit from composite indexes ordered with the equality column first and the range or sort column second, matching the query's shape. Low-selectivity columns (a status with three values) rarely deserve a standalone index on a large table; the optimizer may ignore it anyway.

Measure rather than guess. Every serious engine offers an EXPLAIN-style command that shows whether a query uses an index or scans a table. Run it on your key queries with realistic data volumes — a plan on 100 rows tells you little about behavior on a million. Adding an index takes seconds; removing one from a busy production table may require a careful migration, so be conservative up front.

Check: every query from Step 1 should have a plan you can explain. If a critical query does a full table scan at expected scale, you are missing an index or a modeling change.

Step 7: Handle transactions, concurrency, and integrity under load

Decide which operations must be atomic. Placing an order — decrementing inventory, inserting order rows, recording payment — must either fully happen or not happen at all. Wrap such operations in a transaction, and understand the isolation level your engine defaults to: higher isolation protects against subtle anomalies such as reading data that another transaction later rolls back, at a cost in concurrency.

Two principles prevent most concurrency bugs. First, keep transactions short — no waiting on external APIs inside them. Second, where multiple transactions update the same row (inventory, account balances), use explicit locking or a compare-and-set pattern so the second writer does not silently overwrite the first. A common failure: two concurrent orders each read stock as 1, both decide one remains, both sell the last unit. Optimistic versioning (a version column checked on update) or row locks each fix it, with different throughput characteristics.

Also decide deletion semantics early. Hard deletes are simple but irreversible; soft deletes (an archived_at column) preserve history but every query must filter on them. Whatever you choose, document it, because mixed conventions across tables become a permanent source of bugs.

Check: write a short list of operations that must be atomic and confirm each runs inside a transaction with the locking or versioning it needs.

Step 8: Plan migrations, backups, and sample data

A schema is not final; it changes. Manage changes with versioned migration files — each one recorded and applied in order, with a way to roll back or roll forward. Rehearse migrations against a copy with representative data volume, because adding an index or a non-null column to a large table can lock it for longer than acceptable; many engines offer online or concurrent variants you should verify in their documentation for the version you run.

Backups are part of the design, not an afterthought. Decide the recovery point objective (how much data you can afford to lose) and recovery time objective (how long restoration may take), then confirm the backup scheme meets them — and, crucially, restore one backup to a test environment to prove it works. An untested backup is a hope.

Finally, seed a development database with realistic sample data: enough rows to make indexes matter and enough edge cases (nulls where allowed, boundary quantities, cancelled orders) to catch assumptions. Label fabricated data clearly so nobody mistakes it for production figures during testing.

Check: a teammate can rebuild the schema from scratch by running the migrations in order, and a restore from backup produces a working database.

Common failure modes and how to spot them early

Modeling in tables too soon. Skipping the conceptual step produces schemas that mirror today's screens rather than the domain, and every new feature forces surgery. Symptom: constant "just one more column" migrations. No foreign keys because "the app handles it." It works until a background job, a manual fix, or a second service bypasses the app. Symptom: orphaned rows in reports. Indexes added reactively to every slow query. The write path degrades and nobody notices until load rises. Symptom: write latency creeping with no schema change. Denormalization without an owner. Copies drift. Symptom: two dashboards disagree on the same number. Unbounded growth ignored. A log-like table that grows forever eventually makes every backup and query painful. Plan retention and archival from the start.

These failures share a pattern: they are invisible until data volume or team size increases. That is why the checks at each step matter more than any single choice.

When further work needs a specialist

You can complete steps 1 through 5 confidently as an individual developer. Escalate to a database professional or architect when any of these stop conditions appear: you are designing a system that handles regulated financial or health records; your expected data volume or write rate exceeds what you can confidently estimate and test; you need replication, sharding, or multi-region failover; or you face a migration of a live production database with no maintenance window. These situations are not inherently beyond a careful engineer, but they carry consequences where an experienced second opinion pays for itself. Stop and get that review before committing to an irreversible schema or a production cutover.

The core discipline, though, is within reach: model the domain, normalize it, enforce rules in the database, index for real queries, test the transitions, and treat the schema as a living artifact under version control. Do that, and the database you designed from scratch will keep answering questions long after the first feature ships.