Primary Keys, Foreign Keys & Relationships

Technology Fundamentals

Primary Keys, Foreign Keys & Relationships

1 min readPublished 22 Jul 2026

Track your progress. Sign in to mark this guide complete and build your Job Readiness Score.

Keys are what make a database relational — they uniquely identify rows and link tables together.

Interactive explainer

The Relational Model

Tables, rows, columns and keys — the foundation of SQL.

1Tables2Rows & columns3Keys4SQL

Tap or hover a part to learn more.

Tables

One kind of thing.

A relational database stores data in tables (relations). Each table holds one kind of entity — Customers, Orders, Products — like a well-defined spreadsheet.

Check your understanding

1. What makes a database 'relational'?

2. What kind of language is SQL?

Practise this in AI Interview™

The essentials

  • A primary key uniquely identifies each row (e.g. customer_id) — unique and never null.
  • A foreign key references a primary key in another table, creating a relationship and enforcing referential integrity (you can't reference a customer that doesn't exist).
  • Relationship types: one-to-one, one-to-many (the most common — one customer, many orders) and many-to-many (resolved with a junction table).

Keys are the backbone of JOINs and good design.

Interview Intelligence

How this topic actually shows up in interviews — and how to demonstrate you understand it.

Why employers ask about this

Keys and relationships are fundamental; getting them wrong corrupts data integrity.

Technical questions
Explain primary vs foreign keys and referential integrity.+

PK uniquely identifies a row; FK links to a PK elsewhere; referential integrity stops orphaned references.

Behavioural questions
Tell me about catching a data-integrity issue.+

Show spotting the cause (missing constraint) and fixing it properly.

Real-world scenarios
“You need to link students and courses.”+

Expected answer: That's many-to-many — create a junction table (enrolments) with foreign keys to both.

Employability Intelligence

Where this knowledge takes you — the jobs, skills and certifications it feeds into.

Relevant roles
Data AnalystBackend DeveloperDatabase Administrator
Skills you're proving
KeysReferential integrityRelationships
Recommended certifications
Microsoft DP-900 (Data Fundamentals)Oracle / SQL certifications
Career progression

Databases & SQL → developer/DBA roles.

What employers expect

That you can design a sensible schema and write correct, efficient SQL.

Frequently asked questions

What is a primary key?

A column (or set of columns) that uniquely identifies each row — unique and non-null.

What is a foreign key?

A column that references a primary key in another table, creating a relationship and enforcing referential integrity.

How do you model a many-to-many relationship?

With a junction (bridge) table holding foreign keys to both related tables.

Related guides

Practise what you've learned

Turn this guide into real, evidenced progress

Missiora helps you measure, improve and evidence the capabilities employers actually value — start with the tools best suited to this topic.

M
Published by
Missiora

Missiora is an AI Employability Intelligence platform. Our resources are researched and reviewed by the Missiora team to help you measure, improve and prove your career readiness.