Think Build Implement Repeat
London, UK +44 7367 067226
WhatsApp FOLLOW f in X
  1. Home
  2. Blog
  3. The Data Model Decides Everything After It
Python & Django

The Data Model Decides Everything After It

Designing Django models around what the business does, not the first screen: database constraints, relationships, audit fields and careful migrations.

Updated 2 min readBy SpiderHunts Technologies

Free estimateNo obligation

Get a free estimate

Tell us what you need. A senior engineer reads every enquiry.

Takes under a minute. We never share your details.

  • Free consultation
  • No commitment
  • NDA on request

Prefer to talk? Book a free 30-minute call →

Quick answer — TL;DR

Model what the business actually does, not what the first screen needs. Constraints at the database level, sensible relationships, and audit fields on everything that matters.

Model the business, not the screen

Models designed around the first interface tend to need restructuring as soon as the second one arrives. Model the entities and relationships the business actually has.

The question is not what fields the form needs. It is what a customer, an order or a job actually is in this business, including the awkward cases.

Constraints belong in the database

  • Unique constraints where duplicates must not exist
  • Foreign keys with the right deletion behaviour, decided rather than defaulted
  • Check constraints for values with defined ranges
  • Not-null where a value is genuinely required
  • Indexes on what you will filter and join by

Application-level validation can be bypassed by a management command, a data import or a bug. Database constraints cannot.

Audit fields on anything that matters

  1. Created and modified timestamps on every model
  2. Created by and modified by where accountability matters
  3. Soft deletion rather than hard deletion for business records
  4. A history table for anything disputed or regulated

Adding these later means backfilling data that does not exist. Adding them at the start costs nothing.

Choices and reference data

ApproachSuits
Choices on the fieldFixed, rarely changing, code-level meaning
A related modelBusiness-editable, extensible
Free textAlmost never — it becomes inconsistent

Free text where a defined set belongs is the most common cause of data quality problems in business systems.

Migrations are permanent

Every schema change is a migration that will be applied to production. Review them like code, test them on a production-sized copy, and never edit one after it has been applied anywhere.

Backwards-compatible changes — adding before using, removing later — make rollback practical, which is worth the discipline.

FAQ

Frequently asked questions

The questions readers ask us after this guide.

Still have a question?

Ask us directly — a senior engineer will get back to you.

Ask about your project

How much should we model up front?

The core entities and relationships. Details can be added; fundamental structure is expensive to change.

Should we use soft deletion?

For business records, usually. Hard deletion loses history that is frequently needed later.

What about denormalising for performance?

Only with a measured reason. Premature denormalisation creates consistency problems for a speed gain nobody verified.

How do we handle model changes later?

Migrations, tested on realistic data volumes. Long-running migrations on large tables need planning rather than discovery.

Keep reading

More on Python & Django

Python & Django

An API Other Systems Can Depend On

Designing a Python API service others can depend on: validation at the boundary, consistent errors and status codes, early versioning and documentation.

Python & Django

Moving and Transforming Data Reliably

Building data pipelines in Python that cope with malformed input: restartable stages, quarantining failures, reconciling counts and alerting on absence.

Start here

Data model that no longer fits the business?

That is usually fixable incrementally. Happy to look at how yours is structured.

  1. You tell us what you needTwo minutes on the form, or a message on WhatsApp.
  2. A senior engineer reviews itAnd comes back with questions, a realistic range and an honest view on fit.
  3. Free 30-minute scoping callWe talk through scope, options and a realistic estimate — with no obligation.
Free estimateNo obligation

Talk to someone who builds this

Send a short brief and we will come back with an honest view and a realistic range.

Takes under a minute. We never share your details.

  • Free consultation
  • No commitment
  • NDA on request

Prefer to talk? Book a free 30-minute call →