Skip to content
Custom software

Databases for business software: how to design tables that won’t betray you a year later

The database is the invisible part of business software and the one that decides whether it ages well. The principles we apply on every project.

Team Cloudita

2 min read

Illustrazione: Database per gestionali: come progettare tabelle che non ti tradiscono dopo un anno

Business software can have the most beautiful interface in the world, but if the database is badly designed the problems arrive right on time: reports that do not add up, past prices that change by themselves, mysterious slowdowns as the data grows.

These are the principles we follow when designing the database of business software. They apply to MySQL and MariaDB, but the reasoning is the same with any relational database.

1. Every piece of data in one place only

A customer’s name lives in the customers table, not copied into every booking. Bookings point to the customer with a key. If the customer changes phone number, you update it once and it applies everywhere. It is called normalization, and it is the first defense against inconsistent data.

2. But the past is never rewritten

There is one important exception: historical data. If the front-row umbrella goes from €25 to €30, last year’s receipts must keep saying €25. That is why sales rows store the price applied at that moment, not a link to the current price list.

3. Don’t delete: cancel

In software that touches money we almost never use physical deletion. A cancelled order stays in the database with its status, who cancelled it and when. It is essential to:

  • balance the till;
  • understand what happened when something does not add up;
  • sync multiple copies of the system, as we explain in the article on offline-first software.

4. Constraints in the database, not only in the code

“An umbrella cannot be booked twice on the same day” must not be just a check in the program: it must be a database constraint (a unique index, a foreign key). If a bug shows up one day, or two requests arrive at the same instant, the database says no.

5. Indexes designed around real questions

Indexes make searches fast, but each one has a write cost. We design them from the questions the software asks most often: “umbrellas free today”, “open orders for table 12”, “yesterday’s takings”. With the right index a query goes from seconds to milliseconds.

6. Dates, times and time zones

It looks trivial until daylight saving time arrives. We store dates and times consistently and decide from the start what “a day” means for the business: for a nightclub, Saturday’s takings include two in the morning.

7. Backups you can restore

A backup nobody ever tried to restore is not a backup. We take automatic daily copies and periodically check that they can be brought back. We cover it in the article on the 3-2-1 rule.

If your current software suffers from one of these problems, it can often be fixed without rebuilding everything. Tell us what is happening.

Let's talk

Got a website, a software project or a security question? A real person will get back to you.

Write to us

Keep reading

All articles

Music: "Tech Corporate Startup Promo With Bright Drive" by Alex Morgan, CC BY 4.0 licence. Satellite imagery Esri, Maxar.