---
title: "Relational Databases: Tables, Keys and Relationships"
description: "Data held as tables of rows, with a primary key that identifies one row and a foreign key that points at a row in another table. The relationships between tables are the design, not an afterthought."
canonical: https://lightmysky.com/learn/computing/relational-databases-tables-keys-and-relationships-mt_i7pZV6H902
source: https://lightmysky.com/learn/computing/relational-databases-tables-keys-and-relationships-mt_i7pZV6H902.md
retrieved: 2026-09-12
---

> **Agent view.** This is the Markdown twin of the page, for tools and assistants.
> When to use this site, and the call that answers each job: https://lightmysky.com/agent-instructions.md
> API description (OpenAPI 3.1): https://lightmysky.com/openapi.json · Authentication: https://lightmysky.com/auth.md
> Pricing: https://lightmysky.com/pricing.md · Catalog: https://lightmysky.com/llms.txt · Full catalog: https://lightmysky.com/llms-full.txt
> Every machine-readable file on this domain: https://lightmysky.com/.well-known/ai-catalog.json
> Ask for Markdown with `Accept: text/markdown`, a `.md` address, or `?mode=agent`.

# Relational Databases: Tables, Keys and Relationships

Data held as tables of rows, with a primary key that identifies one row and a foreign key that points at a row in another table. The relationships between tables are the design, not an afterthought.

Subject: Computing · Area: Computer Systems · Ages 17 to 18
Page: https://lightmysky.com/learn/computing/relational-databases-tables-keys-and-relationships-mt_i7pZV6H902

## Ready when they can

- Choose a primary key for a table and justify why it identifies a row
- Link two tables with a foreign key and name the relationship as one-to-many or many-to-many
- Say what goes wrong when the same fact is stored in two places

## Lesson: Tables, keys and the links between them

A relational database stores facts in tables of rows and columns. Each row is one thing, like one student, and each column is one property, like a name. A primary key is the column, or columns, whose value identifies exactly one row, like a student number that is never shared.

**Example.** Imagine students and the clubs they join. Writing the club name inside every student row stores one fact in many places, and the copies drift apart when an update misses a row. Store each club once in a Clubs table, each student once in a Students table, and join them with a Memberships table holding one row per pairing. Nothing is stored twice, so nothing can disagree.

Tables link through foreign keys. A foreign key is a column in one table that holds the primary key of another. That link names the relationship. One author with many books is one to many. Students and clubs are many to many, which is why the middle table carries two foreign keys, one pointing at each side.

**Tip.** Choose a key you can defend. A good key is unique for every row, never empty, and stable over time. Invented numbers usually beat names, because names repeat, change spelling, and get reused. Picture the failure first: two rows sharing a key, or a key you must change later.

**Recap.** Store each fact once, identify every row with a steady key, and link tables instead of copying.

## Practice

8 questions on this page, each with its working shown.

## Needs first

- [Reading and Writing Files, Including CSV](https://lightmysky.com/learn/computing/reading-and-writing-files-including-csv-mt_j5qb4FdkdI)

## Opens up

- [Normalisation to Third Normal Form](https://lightmysky.com/learn/computing/normalisation-to-third-normal-form-mt_cbRXVW6KxX)
- [The Relational Model and Relational Algebra](https://lightmysky.com/learn/computing/the-relational-model-and-relational-algebra-mt_unDBd_Ug8T)
