What is a Database
A database is a collection of related data.
MySQL is the software. The database is the box of tables inside it.
One MySQL server can hold many databases. Like one kitchen with many labeled jars.
Tables, rows, and columns
A table looks like a spreadsheet.
A column is a kind of fact, like name or age.
A row is one item, like one student or one order.
Database: the whole box
Table: one sheet of related facts
Column: a labeled field
Row: one record
A tiny school database
Imagine a school named fox_school.
It might have a students table and a courses table.
| id | name | age |
|---|---|---|
| 1 | Ada | 12 |
| 2 | Sam | 11 |
2 rows
Why not a spreadsheet?
Spreadsheets are fine for small lists.
A database is better when many people read and write at once.
It also checks types, keys, and rules so messy data is harder to save.
SQL lets you ask big questions in one line.
Relational means linked tables
MySQL is a relational database.
Tables can point at each other with keys.
A score row can point at a student row. That is a relationship.
| id | student_id | points |
|---|---|---|
| 1 | 1 | 95 |
| 2 | 2 | 88 |
2 rows
Tip: Name databases and tables with snake_case, like fox_school and quiz_scores.
Test yourself
Three quick questions made just for this lesson. Earn 10 XP per correct answer.