What is a relational database?

BeginnerConceptMySQL
Answer

Short answer

A relational database stores data in tables made of rows and columns, and links tables together using keys. You read and change the data with SQL. MySQL, PostgreSQL, SQL Server and Oracle are all relational databases.

Explained in simple words

Think of a set of Excel sheets that reference each other: a customers sheet and an orders sheet, where each order row has a customer_id pointing at a customer row. The database makes sure those references stay correct.

Example

customers                      orders
+----+-------+-------+         +----+-------------+--------+
| id | name  | city  |         | id | customer_id | total  |
+----+-------+-------+         +----+-------------+--------+
|  1 | Asha  | Pune  |◀────────|  7 |           1 | 52000  |
|  2 | Ravi  | Delhi |         |  8 |           2 |  1499  |
+----+-------+-------+         +----+-------------+--------+

Key properties

  • Schema — every table has defined columns and types.
  • Relationships — primary keys and foreign keys connect tables.
  • ACID transactions — changes are all-or-nothing and consistent.
  • SQL — one standard language to query everything.

What to say in the interview

"A relational database stores data in tables with a fixed schema and links them with primary and foreign keys. It supports SQL and ACID transactions, which is why it's used for orders, payments and user accounts."

All Databases (MySQL, PostgreSQL, MongoDB) questions Roadmap: MySQL basics

More on MySQL