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.

  1. Find the header row in each grid: those are the columns.
  2. Each line below the header is a row, one record.
  3. A thin line connects enrolments to 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.

  1. The app starts and reads a connection string.
  2. It opens a connection to the server's address and port.
  3. The server checks the login.
  4. The app sends SQL; the server sends rows back.
  5. 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.

  1. The app opens the file by its path.
  2. The SQLite library does the database work inside the app's own process.
  3. 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.

  1. You get a host name, port and login from the provider's dashboard.
  2. The connection is usually encrypted, shown by the padlock.
  3. Access is often limited to approved networks, shown by the dotted line.

The diagrams compared

DiagramSeparate server?Where data is storedTypical use
Server databaseyesServer's diskWebsites, shared apps
File database (SQLite)noOne file next to the appLearning, phones, small tools
Cloud databaseyes, run by a providerProvider's storageHosted 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.