aimnova.
DashboardMy LearningPaper MasteryStudy Plan

Aimnova site navigation

Stay in the loop

Get the latest study resources and updates

New features, study tips and exam insights — straight to your inbox.

IB Diploma

  • IB Past Papers
  • IB Study Notes
  • IB Question Bank
  • IB Mock Exams
  • IB Revision

IB Subjects

  • IB Math AA
  • IB Math AI
  • IB Economics
  • IB Business Management
  • IB Physics
  • IB Biology
  • View all IB subjects→

IB Past Papers

  • IB Math AA HL Past Papers
  • IB Math AA SL Past Papers
  • IB Math AI HL Past Papers
  • IB Math AI SL Past Papers
  • IB Economics HL Past Papers
  • IB Economics SL Past Papers
  • IB ESS Past Papers
  • View all past papers→

Study Resources

  • Study Notes
  • Question Bank
  • Mock Exams
  • Flashcards
  • Revision Guide
  • Exam Skills
  • Command Terms
  • Grade Calculator
  • Exam Timetable 2026

Aimnova

  • Features
  • Pricing
  • For Schools
  • For Parents
  • About Us
  • Blog
  • Contact
aimnova.

AI-powered study platform for smarter revision, past-paper analysis and examiner-style feedback.

TermsPrivacyCookies·© 2026 Aimnova. All rights reserved.8afc4e3

Aimnova is not affiliated with or endorsed by the International Baccalaureate Organization (IB).

NotesComputer ScienceTopic 3.2Building tables
Back to Computer Science Topics
3.2.44 min read

Building tables

IB Computer Science • Unit 3

IB exam ready

Study like the top scorers do

Access a smart study planner, AI tutor, and exam vault — everything you need to hit your target grade.

Start Free

Contents

  • From diagram to tables
  • The four kinds of key
  • Why well-defined tables protect the data
  • Exam-style question
The big idea: Each entity in the ERD becomes a table. Each relationship becomes a foreign key.

That is the whole translation — the diagram tells you what to build.
The one rule to get right: In a one-to-many relationship, the foreign key goes in the many table.

Put it on the one side and that row would need an unknown number of columns to hold all the values.

Free preview

This is the free notes preview

You're reading the free notes. Aimnova Pro unlocks the full study experience — and you can try it with your first topic free to keep:

  • FlashcardsLock in vocabulary and key terms with spaced repetition.
  • Practice questionsAnswer exam-style questions and get instant AI marking.
  • Mock exams & past-paper vaultSit full mocks and see exactly how examiners award marks.
  • Personalised study planA daily plan built around your exam date and weak areas.
Start Studying Free Full access to Aimnova Pro · cancel anytime

Primary key

  • Identifies each row uniquely in its own table
  • Must never be empty and never repeat
  • Often a plain ID the database generates itself
  • Every table should have one

Foreign key

  • Holds a primary key value from another table
  • This is how a relationship is physically built
  • The database refuses a value with no matching row
  • Goes in the many table of a one-to-many

Composite and concatenated

  • Composite key — two or more columns used together as the primary key
  • Used when no single column is unique, as in a linking table
  • Concatenated key — a single column made by joining values, such as 2026-S1
  • A composite keeps the parts separate; a concatenated one glues them together

Step to 3NF: PK and FK markers show exactly where each kind of key ends up.

Interactive diagram

Explore the labelled diagram, charts and maps for this topic in full study mode.

Claim your free topic
Composite is usually the right one: A concatenated key looks tidy but hides the parts: you cannot filter on the year without pulling the string apart.

Keep the columns separate and make them the primary key together.

See how examiners mark answers

Access past paper questions with model answers. Learn exactly what earns marks and what doesn't.

Try Exam Vault FreeYour first topic is free to keep • No credit card required

What the definitions enforce

  • Entity integrity — a primary key can never be empty or duplicated
  • Referential integrity — a foreign key must match an existing row
  • Domain integrity — a value must fit the column's data type
  • The database refuses bad data instead of storing it and hoping

What happens without them

  • Two rows for the same student, and no way to tell which is current
  • A membership pointing at a club that was deleted last term
  • A date stored as text, sorting in the wrong order
  • Every program reading the data must re-check it all itself
The argument in one sentence: Rules enforced by the database apply to every program that touches it, including ones written years later.

Rules enforced in a program apply only to that program.

How this is tested — you must place each key in the right table and say what it enforces. It comes up two ways:

Paper 1 Section A

  • Construct tables from an ERD or scenario, 4-6 marks
  • Identify the primary and foreign keys
  • Explain how keys maintain data integrity

Paper 1 Section B — case study

  • Build the tables for the case study's data
  • Explain what a given key prevents
The classic trap: Putting the foreign key on the one side of a one-to-many. If a teacher takes five classes, a TeacherID row cannot hold five ClassIDs — the key belongs in the Class table.
IB-style questionConstruct[5 marks]

A library lends books to members. Construct the tables needed, stating the primary and foreign keys for each.

Model answer plan

See the mark-by-mark plan — for / against / judgement, with marking guidance — in study mode.

Claim your free topic

Try an IB Exam Question — Free AI Feedback

Test yourself on Building tables. Write your answer and get instant AI feedback — just like a real IB examiner.

the SQL command used to create a new table. [1 mark]

Related Computer Science Topics

Continue learning with these related topics from the same unit:

3.1.1Relational databases
3.2.1Database schemas
3.2.2ERDs
3.2.3Data types
View all Computer Science topics

Improve your exam technique

Command terms, paper structure, and mark-scheme tips for Computer Science

Previous
3.2.3Data types
Next
Normal forms3.2.5

20 exam-style questions ready for you

Students who practice on Aimnova improve their scores by 15% on average. Get instant feedback that shows exactly how to improve your answers.

Practice Now — FreeView All Computer Science Topics