ThisCalculator

Everyday

Why Database Is a Detail but Data Model Is Not

Updated · Standard formula, shown below

Average pace 5.00 min/km
Average speed
12.00 km/h
Result
Finish time
50 min
You entered
Distance
10 km
You entered

This article explains why the choice of database technology (PostgreSQL, MySQL, MongoDB, etc.) is a detail that can be changed later, while the data model—the structure of your tables, relationships, and constraints—is the backbone of your application that is extremely costly to change once built. The short answer: your data model encodes the fundamental business rules and relationships that every feature depends on, while the database is just a storage engine that can be swapped out with effort, but the model is the contract your entire codebase is built against.

Formula

This calculator computes two related quantities: average pace and average speed.

  • pace (min/km) = finish time (minutes) ÷ distance (km)
  • speed (km/h) = distance (km) ÷ (finish time (minutes) ÷ 60)

Variables:

  • t = finish time, in minutes (e.g., 50 min)
  • d = distance, in kilometers (e.g., 10 km)
  • pace = minutes per kilometer
  • speed = kilometers per hour

Worked Example

Using the default values (t = 50 min, d = 10 km):

  1. Pace = 50 ÷ 10 = 5.00 min/km
  2. Speed = 10 ÷ (50 ÷ 60) = 10 ÷ 0.8333 = 12.00 km/h

The calculator returns a pace of 5.00 min/km and a speed of 12.00 km/h.

Why the Database Is a Detail

The database is the software that stores, retrieves, and manages your data. It is a commodity in many ways—there are dozens of mature options (PostgreSQL, MySQL, SQL Server, Oracle, MongoDB, etc.) that can all handle the same logical data model with varying degrees of performance, cost, and operational complexity. The choice of database is often driven by infrastructure constraints, team familiarity, or scalability needs, but it is rarely a business-defining decision. You can migrate from one database to another without changing the meaning of your data—only the way it is physically stored and queried.

For example, you could move from a self-hosted PostgreSQL instance to a cloud-managed MySQL database and, with some SQL dialect adjustments, your application would continue to work. The data itself—the customer records, orders, and products—would remain semantically identical. The database is a tool, not the design.

Why the Data Model Is Not

The data model is the logical structure of your data: the entities (e.g., Customer, Order, Product), their attributes (e.g., customer name, order date), and the relationships between them (e.g., a customer has many orders, an order contains many products). This model is the foundation of your application’s business logic. Every query, every API endpoint, every validation rule, and every report is built against this structure.

Changing the data model is not like swapping a storage engine. It means altering the core contract that your code, your APIs, and often your third-party integrations rely on. For instance, if you initially model a customer as having a single email address and later need multiple emails, you must:

  • Create a new table or alter the existing one
  • Update all queries that assume a single email
  • Change the API responses to return an array of emails
  • Migrate existing data
  • Update all client applications that consume the API

This is not a small task. It touches every layer of the stack and can take weeks or months, whereas changing the database vendor might take days or weeks with proper planning.

How the Two Interact

Your data model is expressed in the database’s schema (tables, columns, constraints, indexes). The database enforces the model’s integrity through primary keys, foreign keys, unique constraints, and check constraints. But the model itself is independent of the database—you could implement the same model in a relational database, a document store, or even a flat file, though with different trade-offs.

The key insight is that the data model represents the what of your data, while the database represents the how of storing and accessing it. The “what” is much harder to change because it is the foundation of your domain logic.

Common Mistakes When Treating Database as the Model

A frequent mistake is to let the database’s capabilities dictate the data model. For example, using a NoSQL document store and then designing your entities to be large nested documents because that is how the database works, rather than designing a normalized model that reflects true relationships. This leads to data duplication, inconsistent updates, and painful refactoring later.

Another mistake is to over-index on database features (like JSON columns) for flexibility, but then lose the ability to enforce relationships and constraints at the database level. This can lead to data integrity issues that are hard to trace.

Also, many developers underestimate the cost of changing a data model after launch. They think “we’ll just add a column later,” but adding a column is easy; changing the meaning of a column or splitting a table is not.

How to Choose a Database and Model

When starting a new project, focus first on the data model. Identify the core entities and their relationships. Use entity-relationship diagrams or UML class diagrams to visualize them. Then, choose a database that fits the model and your operational needs. For most business applications, a relational database (like PostgreSQL) is a safe default because it supports ACID transactions, joins, and constraints that protect data integrity.

Consider a document store (like MongoDB) only if your data is naturally hierarchical and you do not need multi-object transactions or complex joins. But even then, you should still design a clear logical model—just expressed as documents.

Also, consider future evolution. A data model that is normalized (avoiding redundancy) is generally easier to evolve than one with heavy duplication. But over-normalization can hurt performance, so balance is key.

Costs of Changing the Model vs. Changing the Database

Changing the database vendor involves costs: new connection drivers, SQL dialect differences, migration scripts, re-testing, and possibly re-architecting some queries. But these are mostly mechanical.

Changing the data model involves costs that ripple through the entire application:

  • Code changes in every layer (data access, business logic, presentation)
  • API versioning or breaking changes
  • Data migration and backfill scripts
  • Testing and validation for data consistency
  • Potential downtime during migration
  • Retraining for developers and users

In practice, a database migration might take a team a few weeks, while a significant data model change (like splitting a table or adding a polymorphic relationship) can take months and may require a full rewrite of some services.

Frequently Asked Questions

Can I change the data model without changing the database?

Yes. You can alter the schema (add columns, new tables) without changing the database vendor. For example, adding a new table for “addresses” to support multiple addresses per customer is a data model change that stays within the same database.

Is the database completely unimportant?

No. The database matters for performance, scalability, backup, and availability. But these are operational concerns, not business-logic concerns. You can often fix performance issues by tuning indexes or adding caching, without changing the model.

What if I use a NoSQL database—does that change the answer?

No. The principle holds. Even in a document store, the shape of your documents is your data model. Changing that shape is just as costly as changing tables in a relational database.

How do I know if my data model is good?

A good data model accurately reflects the business domain, avoids unnecessary duplication, and can accommodate likely future changes without breaking existing features. It is typically normalized to some degree, but not to the point of absurdity.

Should I always use a relational database?

Not always, but it is a safe default. If your data is highly relational and requires transactions, relational is the way. If you have massive scale-out needs and your data is document-like, NoSQL might be better. But the data model still comes first.

Can I change my database later if I chose wrong?

Yes, but it is not trivial. You will need to export data, rewrite queries, and update connection code. It is easier if you have kept your data access layer abstracted, but it is still a significant project. Changing the data model later is even harder.

Related

Formula used
in t | Finish time | min | 50 | 0
in d | Distance | km | 10 | 0
out pace | Average pace | min/km | t / d | 2
out speed | Average speed | km/h | d / (t / 60) | 2

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.