Skip to content
Blog

Software Development

5 Database Design Mistakes That Will Haunt You Later

Five database design decisions that seem harmless at first and turn into expensive problems at scale, plus what to do instead from day one.

Giovani Rodríguez7 min read
Close-up of code on dark screen
Photo: Lukas

The Decisions That Don’t Seem Like Decisions

Shortcuts in database design cost you the most. Every feature, query, and migration you write for years has to work with the schema you sketched on a whiteboard in week one. A design choice that feels inconsequential at 500 rows can threaten the product at 5 million.

We’ve inherited, audited, and rebuilt enough databases to see the same patterns repeat. Below are the five mistakes that cause the most pain, along with fixes that would have taken minutes at the start.

Mistake 1: Not Using UUIDs from the Start

Why It Seems Fine

Auto-incrementing integers are the default in almost every database tutorial. They’re simple, sequential, and human-readable. User #1042 is easier to reference in conversation than User 7f3a9b2c-4d1e-4f8a-b6c7-8d9e0f1a2b3c. For a single application with a single database, integer IDs work fine.

When It Bites You

Trouble starts when your system outgrows a single database. If you ever need to merge databases, replicate data across regions, sync with a mobile client, or expose IDs in a public API, integer IDs create collisions and security risks.

Sequential integers also leak information. If a competitor creates an account on your platform and gets user ID 14,200, they know you have roughly 14,200 users. If they check back in a month and get ID 14,350, they know your growth rate. In APIs, sequential IDs enable enumeration attacks: an attacker can iterate through /api/users/1, /api/users/2, /api/users/3 to scrape your entire user base.

The Fix

Use UUIDs (v4 or v7) as primary keys from day one. In PostgreSQL, use the gen_random_uuid() function or the uuid-ossp extension. In SQL Server, use NEWID() for random UUIDs or NEWSEQUENTIALID() for index-friendly sequential ones.

If you worry about index performance with random UUIDs (a valid concern for B-tree indexes), use UUIDv7, which embeds a timestamp component that keeps inserts roughly sequential. PostgreSQL 17+ supports UUIDv7 natively, and SQL Server’s NEWSEQUENTIALID() achieves a similar result.

Migrating from integer to UUID primary keys on a table with millions of rows and foreign key relationships is one of the most painful database migrations you can face. Doing it from the start costs nothing.

Mistake 2: Skipping Soft Deletes

Why It Seems Fine

Hard deletes are clean. DELETE FROM users WHERE id = ? removes the row, the database stays smaller, and you never wonder what’s active. Your queries don’t need WHERE deleted_at IS NULL on every statement.

When It Bites You

A customer calls: “I accidentally deleted my account, can you restore it?” With hard deletes, you answer “only if we have a backup, and restoring it will take hours.” With soft deletes, you answer “done.”

Soft deletes are often a compliance requirement, too. GDPR requires that you can demonstrate what data you held and when you removed it. Financial regulations may require audit trails that include deleted records. Healthcare applications under HIPAA can’t destroy records because someone clicked a button.

Even without regulatory pressure, hard deletes break referential integrity. If you delete a user whose orders, comments, or transactions still reference their ID, you have orphaned records pointing to a ghost. Foreign key constraints will either block the delete or cascade it in ways you didn’t intend.

The Fix

Add a nullable deleted_at timestamp column to every table that represents a business entity. NULL means active; a timestamp means deleted. Create a database view for each table that filters out deleted records, and point all application queries at that view. Your queries stay clean and nobody has to remember the WHERE clause.

In PostgreSQL, a partial index on WHERE deleted_at IS NULL keeps the soft delete column from degrading query performance for active records. In SQL Server, filtered indexes achieve the same result.

Mistake 3: Over-Normalizing or Under-Normalizing

Why It Seems Fine

Courses teach database normalization, organizing data to reduce redundancy, as a virtue, and up to a point it is one. Third normal form (3NF) is a solid default for most applications. The trouble starts when developers treat normalization as a binary: either a dozen joined tables or one flat table.

When It Bites You

Over-normalization turns simple queries into multi-table joins that crawl as data grows. We’ve seen schemas where retrieving a user’s profile required joining seven tables (user, address, phone, email, preferences, roles, and permissions) for data the application always read together. Each page load sent the database a query its optimizer struggled to plan.

Under-normalization creates update anomalies. If you store a customer’s city name directly on the order table instead of referencing a normalized address, changing that customer’s city means updating every order they’ve placed. Miss one and your data is inconsistent.

The Fix

Normalize for correctness, denormalize for performance, and document why. Start in 3NF. When a query becomes a bottleneck, denormalize on purpose: add a computed column, create a materialized view, or duplicate a frequently accessed field. Make each denormalization a deliberate decision with a comment explaining the trade-off, so none of them come from a rushed schema.

In PostgreSQL, materialized views with REFRESH MATERIALIZED VIEW CONCURRENTLY give you denormalized read performance while the source tables stay the source of truth. In SQL Server, indexed views serve a similar role.

Mistake 4: No Audit Trail

Why It Seems Fine

When you’re building fast, tracking who changed what and when feels like overhead. The application works. Users can create, update, and delete records. Nobody has asked for an audit log, so the extra complexity seems unjustified.

When It Bites You

Audit trails become mandatory the first time someone asks “who changed this record and when?” and you can’t answer. The question might come from a customer disputing a charge, a manager investigating a data discrepancy, or a compliance officer asking for evidence of access controls.

Without an audit trail, your only option is combing through application logs, assuming they exist, carry enough detail, and haven’t been rotated. You’d be relying on luck.

The Fix

Create a changes or audit_log table that records the table name, record ID, field name, old value, new value, user ID, and timestamp for every update and delete. In PostgreSQL, trigger functions can automate this. They fire on INSERT, UPDATE, and DELETE and write to the audit table with no application code changes.

In SQL Server, temporal tables (system-versioned tables) provide built-in audit functionality. Enable them with ALTER TABLE ... ADD PERIOD FOR SYSTEM_TIME and SQL Server tracks the full history of every row.

Audit tables cost you trivial storage compared to what you lose without them. Even at scale, audit data compresses well, and you can partition it by date for efficient archival.

Mistake 5: Ignoring Indexes Until Performance Tanks

Why It Seems Fine

Indexes are invisible. The application behaves the same whether a query uses an index or scans the full table, at least while the table has 1,000 rows. Index management also adds work: you have to choose the right columns, understand composite index ordering, and watch for unused indexes that slow down writes.

When It Bites You

A query that takes 2ms on 10,000 rows can take 15 seconds on 10 million rows without the right index. We’ve seen production databases where one missing index turned a 50ms API response into a 12-second timeout. The fix took five minutes; finding the problem took a weekend of panic.

The Fix

Index every foreign key column. This is non-negotiable. Without an index on a foreign key, every join on that relationship is a sequential scan. PostgreSQL does not create indexes on foreign key columns automatically (unlike some other databases), so you must add them yourself.

Index columns that appear in WHERE, ORDER BY, and GROUP BY clauses. Use EXPLAIN ANALYZE in PostgreSQL or execution plans in SQL Server Management Studio to find sequential scans on large tables.

Monitor for missing indexes before users notice. PostgreSQL’s pg_stat_user_tables shows sequential scan counts by table. SQL Server’s sys.dm_db_missing_index_details DMV lists the indexes that would improve query performance. Set up alerts for queries that exceed a time threshold and review the execution plans monthly.

Build indexing into your development workflow. Every migration that adds a column used in queries should include the index. Add it now, while the table is empty and the cost is zero, instead of saving it for a later performance pass.

Conclusion

You can avoid all five of these mistakes with little effort. UUIDs, soft deletes, sensible normalization, audit trails, and indexes are straightforward to implement at the start of a project. Getting them right on day one costs minutes. Fixing them later costs weeks and downtime.

If you’re building a new application and want the database designed right from the start, or you’re dealing with the consequences of one that wasn’t, we’d like to help.

  • #Database
  • #SQL
  • #Architecture
  • #Backend
  • #Performance

Share

Get in touch

Let’s buildsomething great.

Tell us what you’re working on. We take on AI automation, custom SaaS platforms and technical strategy work.