Diagrams of What a Database Is and Where It Lives
Words like "server", "file" and "cloud" can make databases feel abstract. These described diagrams show where a database actually lives and how an app reaches it. Each has a caption and a numbered walkthrough you can follow with your finger, or sketch yourself.
Diagram 1: a database is a set of tables
Picture: three rectangles labelled students, courses and enrolments, each drawn as a grid with a header row.
Caption: inside a relational database, data lives in tables. Each table holds one kind of thing.
- Find the header row in each grid: those are the columns.
- Each line below the header is a row, one record.
- A thin line connects
enrolmentsto both other tables. Those lines are relationships, made with keys.
Diagram 2: a server database
Picture: a laptop on the left labelled "your app", a box on the right labelled "database server", and a cable between them marked "network, port 5432".
Caption: PostgreSQL, MySQL and SQL Server run as server programs. Apps connect to them over a network, even when both run on the same computer.
- The app starts and reads a connection string.
- It opens a connection to the server's address and port.
- The server checks the login.
- The app sends SQL; the server sends rows back.
- Many apps can connect to the same server at once.
Diagram 3: a file database inside the app
Picture: a single box labelled "your app", containing a smaller box labelled "SQLite library", with an arrow to a file icon called app.db.
Caption: SQLite has no separate server. The library runs inside your program and reads and writes one file.
- The app opens the file by its path.
- The SQLite library does the database work inside the app's own process.
- Copying the file copies the whole database.
Diagram 4: a cloud database
Picture: your app in one cloud box, a managed database in another, both inside a dotted line labelled "provider's network", with a padlock on the connection.
Caption: a managed database is a server run for you by a hosting provider. It is still a server; someone else installs, patches and backs it up.
- You get a host name, port and login from the provider's dashboard.
- The connection is usually encrypted, shown by the padlock.
- Access is often limited to approved networks, shown by the dotted line.
The diagrams compared
| Diagram | Separate server? | Where data is stored | Typical use |
|---|---|---|---|
| Server database | yes | Server's disk | Websites, shared apps |
| File database (SQLite) | no | One file next to the app | Learning, phones, small tools |
| Cloud database | yes, run by a provider | Provider's storage | Hosted apps |
Sketch it yourself
Draw diagram 2 or 3 for the project you are building. Label your app, the database, and the line between them. If you are unsure what goes on the line, look at your connection string; it describes that line exactly. For a moving version of these ideas, see How an App Talks to a Database, in Annotated Pictures.
A free learning page for beginners. Practise on a test database, never on real customer data, and check the official documentation for your database version.