Skip to content

Under the hood

What is a database? A simple explanation with examples

A database is an organised store of information an app can save, search and update. Tables, rows, SQL queries and keeping data safe, explained simply.

By the GenKid team · · Updated · Facts checked · 5 min read

Key takeaways

  • A database is an organised store of information that an app can save to, search and update, so the information is still there after the app closes.
  • Many databases organise data into tables, with columns for each kind of information and rows for each item.
  • Apps use queries to ask databases for data: "find all tasks that aren't done yet".
  • Databases usually sit in the back end, behind checks that decide who can see or change what.
  • Storing data about people is a big responsibility: collect only what you need and protect it.

What is a database?

A database is an organised store of information that an app can save to, search and update. It keeps data safe after the app closes, and lets many people use the same data at once.

Imagine a to-do app. You add three tasks, close the page, and come back tomorrow. Without somewhere to store them, your tasks are gone. Variables in your code only last while the page is open.

A database solves this. It's a place to store information so an app can save it, find it and update it later — even when millions of people use the app at once.

You use databases all the time: your contacts, a shop's products, a game's high scores, a library catalogue.

Tables, rows and columns

Many databases — called relational databases — store data in tables, a bit like spreadsheets:

idtaskdone
1Feed the robotyes
2Map the moonno
3Fix the rocketno
  • Each column is one kind of information: the task text, whether it's done.
  • Each row is one item: one task.
  • The id gives each row a unique number so it can be found exactly.

Bigger apps have many tables that link together — a "users" table and a "tasks" table, for example, where each task records which user it belongs to.

What is SQL? Asking the database questions

To get data, apps send the database a query. Many databases use a language called SQL (Structured Query Language, often said "sequel"):

SELECT task FROM tasks WHERE done = 'no';

This asks: "give me the task text for every task that isn't done". The answer would be "Map the moon" and "Fix the rocket".

SQL can also add, change and delete data. For example, UPDATE tasks SET done = 'yes' WHERE id = 2; ticks off "Map the moon".

There are also non-relational (sometimes called NoSQL) databases, which store data in other shapes, such as documents. The idea is the same: organised storage you can query.

Database vs spreadsheet

A table in a database looks a lot like a spreadsheet, and a spreadsheet is a fine way to keep a small list yourself. The difference is who uses it. Databases are built for apps: they handle many users reading and writing at the same time, enforce rules (such as "every task must have text"), link tables together and answer queries quickly even with millions of rows.

Where the database lives

Databases usually live in the back end, on a server. The front end doesn't talk to the database directly; it asks the back end, often through an API, which checks the request and then queries the database. MDN's guide to the server side describes how dynamic websites build pages by reading data from a database. See front end vs back end and, for where that server lives, what web hosting is.

Some services let front ends reach a database more directly, but only with strict security rules that decide who can read or write each row. Getting those rules wrong is a common way data leaks.

Keeping data safe

Storing data, especially about people, comes with responsibility:

  • Collect only what you need. If your app doesn't need someone's birthday, don't ask for it. This is also a legal principle in many countries: the UK's Children's code lists data minimisation as one of its standards. See also children's privacy laws around the world.
  • Control access. Make sure users can only see and change their own data. "Broken access control" is the number one risk in OWASP's 2025 list of web security risks.
  • Never build queries by gluing in user text. Use the safe methods your tools provide, or someone could type a command instead of data — this is called SQL injection, and injection is also on OWASP's 2025 list (at number five).
  • Keep database passwords secret and out of code. See API keys and secrets.
  • Back up important data.

Learning databases safely

Young learners can understand databases long before they set one up for real. In GenKid, Levels 1 and 2 use a simulated database inside the sandbox, so learners practise saving and querying data with no accounts and no real personal information. At Level 3, learners explore real database services as their terms allow (see age limits for developer tools). See the pathway. For a project idea, try a to-do app that saves tasks — one of our app ideas for kids.

Frequently asked questions

What is a primary key?

A primary key is a column whose value is different for every row, like the `id` column in the tasks table. It lets the app point to exactly one row — "mark task 2 as done" — even if two tasks have the same text. Other tables can store that key to link to the row, which is how a task records which user it belongs to.

Can I use real people's details when I practise?

It's best not to. Practise with made-up data — robot pets, imaginary planets, fictional players — so nothing personal can leak if you make a mistake with access rules. Real personal data needs proper security and, in many countries, legal care.

Do I need a database for my app?

Only if your app needs to remember information after the page closes, or share data between people or devices. Many beginner apps don't need one.

Sources

  1. Introduction to the server side (opens in a new tab) — MDN Web Docs
  2. OWASP Top 10:2025 (opens in a new tab) — OWASP Foundation
  3. Age appropriate design: a code of practice for online services (opens in a new tab) — Information Commissioner's Office

How we write: GenKid articles are researched and drafted with the help of AI tools, then checked in a separate review step against the sources listed above before they are published, and re-checked when they are updated. Rules and products change, so check official pages for your country before acting on anything here. This article is general information, not legal advice. Spotted a mistake? Email hello@genkid.app.

Under the hood

Front end vs back end: what's the difference?

The front end is the part of an app you see and use; the back end runs on a server and stores data. A simple guide, and why the split matters for safety.

5 min read