Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Learn the Basics  ›  Lesson

What Is a Relational Database?

What are Relational Databases? 12 minA relational database stores each kind of thing in its own table of rows and columns and links tables together through shared key values.

What Is a Relational Database?

Imagine a small online shop that keeps its records in one giant spreadsheet. Every time Asha places an order, someone types her name, her city and her email again. When she moves from Pune to Delhi, half her rows get updated and half do not, and now the shop has two versions of the truth. A relational database exists to stop exactly this.

The rule

One thing per table, one fact per row, linked by keys.

A relational database stores data in tables (the formal name is relations). Each table holds one kind of thing: customers, products, orders. Each row is one instance of that thing, and each column is one detail every row has. One column, the primary key, gives every row a unique identity, like customer_id.

Tables connect by storing another table's key. An order does not copy Asha's name and city; it stores her customer_id, and the database can look up the rest whenever you ask. That stored key is called a foreign key.

This is the small shop we will use for the whole course:

customers (customer_id, name, city, email, joined_on)
products  (product_id, name, category, price)
orders    (order_id, customer_id, product_id, quantity, order_date, status)

Asha's city lives in exactly one row of customers. Change it once and every order that points to her sees the new city automatically.

You talk to a relational database in SQL (Structured Query Language). You describe what you want — "every order from a customer in Pune" — and the database works out how to fetch it.

The shortcut

When you meet any new set of data, sort every word in its description into four buckets: noun → table, instance → row, detail → column, "belongs to" → key.

Turning a sentence into tablesStep 1 of 4
  1. Read the sentence

    "Asha from Pune ordered 2 notebooks priced at 60 rupees each on 3 March."

The trap to watch for: a detail that repeats across many rows (like Asha's city on every order) is a sign it belongs in a different table.

Drills

Answer fast — trust the rule.

quick drill

In the customers table, a single customer such as Asha is stored as one…

quick drill

Why does orders store customer_id instead of the customer's name and city?

quick drill

In relational database theory, what does the word relation formally mean?

quick drill

Which column is the best choice to identify each row of products uniquely?

Remember

  • One thing per table, one fact per row, linked by keys.
  • Noun → table, instance → row, detail → column, "belongs to" → key.
  • A detail copied onto many rows is a warning sign: it probably belongs in its own table.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainWhy not keep everything in one big table?

A shop keeps one table where every order row also stores the customer's name, city and email. Explain what goes wrong over time, and how splitting the data into customers and orders tables linked by customer_id fixes it.