Software
Databases
A database is an organised collection of stored data. Put another way, it’s a place where information is stored so it can be accessed and used later.
Databases are a fundamental part of the technology world, and almost every software product, website and app uses them.
So how do they work?
Tables, columns & rows
Most databases use tables, columns _and _rows to store information like a giant spreadsheet.
Each table can represent a collection of data (like Users or Music), and these tables can have relationships with each other. Let’s look at an example.
When you open up Instagram, the app makes a number of requests to Instagram’s servers, which then query Instagram’s database (or, more realistically, databases) for data. While I can’t claim to know the exact structure of their systems, for our example, we will assume it’s similar to the simplified design I’m outlining below.
Their database will have a User table containing key information about Instagram’s users.
The table will have column_s for each user _attribute: the things we’re using to define each user, like a unique ID, username, email address and password.
Each row in the user table contains the information for one user.
An application like Instagram will have databases with millions or even billions of rows of data.
Instagram will have other tables in their database to store other important information, like records of the photos uploaded to the service.
If you look in the Photo Table screenshot above, it has a “User ID” column, just like the User Table. If you look closely, you’ll see that some of the User IDs in each table match. This is an example of how we can form a relationship between the two database tables – we are saying, “This photo in the database belongs to the user with ID 1234”.
When you open up your profile screen on Instagram, the server knows it needs to grab all of the photos you’ve posted, so they do a query (a kind of search) on its database to look for all of the photos related to you.
In a relational database, _this query will usually be written in a special language called _SQL (Structured Query Language), so some of the most popular databases have names that include this acronym, like MySQL and PostgreSQL. If you intend to end up in a technical role like programming or data science, you’ll be working regularly with databases, so it would be worth taking some time to learn the basics of SQL.