JEEKSSHIRE 24

The web application database: why you need it and how it works

A web application database is where the service keeps everything users work with: accounts, orders, statuses, documents, action history. The browser shows the interface, the server runs the logic, and the database makes sure data is saved, stays consistent and can be found quickly. For a business, what matters is less the names of technologies than a well-designed data structure, backups with tested restores, careful migrations and responsible handling of personal data.

Open the software development page

Why a web application needs a database

An ordinary website can do without a database: its pages are the same for everyone. A web application is different. People work in it: they sign in to their own accounts, place orders, change statuses, upload documents. All of this has to be stored somewhere so that data is not lost when the server restarts, does not get mixed up between users and is still available a month or a year later.

A database solves several problems at once:

How a web application differs from a website and what kinds there are is covered in our guide on what a web application is.

How it fits together: browser, server and database

A typical web application has three layers. The interface in the browser (the frontend) shows the screens and sends requests. The server side (the backend) checks permissions, runs the business logic and talks to the database. The database stores and returns records.

An important rule: the browser never talks to the database directly. All requests go through the server, which checks who is asking and what they are allowed to do. Calculations that affect money and permissions also run on the server, and the user is shown the result. This protects the database from forged requests and keeps the logic from being duplicated in several places.

Relational and document databases: an overview

There are many databases, but for most business tasks the choice comes down to two families.

Relational (SQL)Document
How data is storedTables with rows and columns, links between tablesDocuments with nested fields; structure can vary
StrengthsConsistency, relationships, complex queries and reports, transactionsFlexible structure, convenient for data of different shapes
Where they fitOrders, payments, accounting, CRM, personal accountsCatalogs with varied attributes, event logs, settings
What to keep in mindThe structure must be designed in advance and changed through migrationsWithout discipline it is easy to end up with inconsistent fields and duplicates

In practice a relational database is a common default for business applications: they have many linked entities (customer, order, payment, document) and accuracy matters. A document database or a separate store is added where data really is varied. The choice is made for the task, not for fashion, and explained in terms of the task rather than the stack.

What to keep in the database and what to keep next to it

Not everything an application works with belongs in one database. A typical split looks like this:

Data structure: design it before the code

Mistakes in the data structure are the most expensive to fix later, because screens, reports and integrations rely on it. That is why the data structure, roles and access rights are designed early, together with user scenarios.

Migrations: changing the database without losses

An application evolves, and the database structure changes with it: a new field appears, a table is split in two, a format changes. Doing this by hand on a live server is risky. That is what migrations are for: step-by-step descriptions of changes that are stored with the code and applied the same way on every server.

Backups

A backup is needed not just in case but for specific events: a faulty update, accidental deletion, a server failure. A good scheme answers three questions.

Backups and failure alerts are part of what the client receives with a finished web service, and checking them regularly is part of maintenance. How it works is described on the software support and development page.

Personal data

Almost every business application stores personal data: names, phone numbers, addresses, order history. It comes with special requirements, both from the laws of the country you operate in and from common sense.

The requirements of a specific jurisdiction are worth checking with a lawyer before design, not after launch.

Performance: why an application starts to slow down

At the start there is little data and everything is fast. A year later there are hundreds of times more records, and screens that used to open instantly start to lag. The cause is usually in the database, and it can be found.

The fixes are targeted: measure slow queries, add indexes, paginate results, move reports and heavy tasks to background processing. Rewriting the whole application is usually not necessary.

Moving data from spreadsheets and old systems

A new application rarely starts with an empty database: customers, orders and reference data already live in spreadsheets or an old system. The transfer is planned as a separate task: fields are mapped to the new structure, duplicates and inconsistent formats are cleaned up, and a trial load and reconciliation are carried out. More on such transfers is in our guide on CRM development for your process, and on linking the new database to other systems, see the business process automation page.

How we approach data in web applications

We plan the data structure, access rights and multiple languages at the design stage, not right before launch. Money is calculated on the server, secrets are kept outside the code and the repository, and together with the service the client receives configured backups and failure alerts. We choose the database technology for the task and explain the choice. More on the web app development page, and you can describe your task on the software development page. How an application comes together as a whole is covered in our guide on business app development.

Frequently asked questions

Why does a web application need a database?

To store accounts, orders, statuses and history reliably, avoid losing data in failures, let many users work at the same time and find the right records quickly.

Which database to choose: relational or document?

For business applications with linked data such as orders, payments and customers, a relational database is the more common choice. A document database suits varied data. The choice is made for the task.

Can files be stored in the database?

Technically yes, but files usually go into separate file storage while the database keeps a link and a description. That keeps the database compact and fast.

What is a database migration?

A step-by-step description of a change to the database structure, stored with the code and applied the same way on every server. Migrations are tested on a copy of the data before they are applied.

How often should backups be made?

It depends on how much data you can lose without harm. What matters is keeping copies separate from the main server and regularly testing restores.

Why has the web application become slow?

Most often because data has grown: missing indexes, lists loaded in full, reports built at peak hours. It is fixed with targeted changes, without rewriting the application.

How do you protect personal data in the database?

Collect only what is needed, separate access by role, encrypt data in transit, keep an access log and decide in advance where the data is physically stored.

IP geolocation by DB-IP