HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Notes
  2. /Database Tables and Keys: Quick Revision
Computer Science

Database Tables and Keys: Quick Revision

A brief note on database tables and keys: records, fields, the six data types, the primary key and the validation checks, with a worked example, practice, a program and questions to check yourself.

StemPy LabWritten by StemPy Lab
Log in to save

A brief note on Database Tables and Keys. Read it before a test. Try each question at the end before you open its answer.

The words

  • Single-table database: all the data is in one table.
  • Record: one row, all the data about one item.
  • Field: one column, one item of data about every item. Its heading is the field name.
  • Data items: records times fields.

The six data types

  • Text (alphanumeric): names, codes such as M01, phone numbers.
  • Character: exactly one character, such as a grade B.
  • Boolean: TRUE or FALSE.
  • Integer: a whole number, such as an age.
  • Real: a number with a decimal part, such as a price.
  • Date/time: a date, a time, or both.

The primary key

  • A field whose value is unique in every record and never empty.
  • It identifies exactly one record.
  • Check every value for repeats, and think about future records too.
  • If no field is unique, add an ID field.

Validation

  • Range: between a lowest and a highest value.
  • Length: the right number of characters.
  • Type: the right data type.
  • Presence: not left empty.
  • Format: a pattern of characters.
  • Check digit: the last digit is worked out from the others.
  • Validation checks that data is sensible, not that it is correct.

A worked example

A swimming pool stores, for each lesson, the day, the start time, the number of places and whether a teacher is booked.

  1. Fields. LessonID, Day, StartTime, Places, TeacherBooked.
  2. Data types. Text, text, date/time, integer, Boolean.
  3. Primary key. LessonID, because two lessons can be on the same day.
  4. Validation. Places: type and range check. Day: presence check.

Practice with new numbers

A program to try

The program builds a table with a primary key, then shows that SQLite refuses a record whose key is already used.

Read it first. Then run it. Which record is refused?

1. Give the refused record the key T4. Predict the number of records at the end.

Mistakes to avoid

  • Record and field mixed up. A record is a row, a field is a column.
  • Phone numbers as integers. They lose the first 000.
  • A name as the key. Names repeat.
  • Validation as proof. A sensible value can still be wrong.

Check yourself

  1. A table has 666 fields and 111111 records. How many data items does it hold?
  1. Which data type suits a field IsMember?
  1. Which check rejects an empty Surname?
  1. Why is Town a poor primary key?
  1. A range check accepts whole numbers from 333 to 888. Which four test values check both ends?

Sources

  • Cambridge International, IGCSE Computer Science 0478 syllabus (exams in 2026, 2027 and 2028), section 9 Databases, and the validation checks of section 7.5.
← All Notes
← Arrays and Files: Quick RevisionSELECT, WHERE and ORDER BY: Quick Revision →
More onComputer Science › Databases and SQL

Discussion (0)

Log in to join the discussion.

Loading…

On this page

  1. The words
  2. The six data types
  3. The primary key
  4. Validation
  5. A worked example
  6. Practice with new numbers
  7. A program to try
  8. Mistakes to avoid
  9. Check yourself
  10. Sources

Goes with the lesson

  1. Validation in a database table
Database Tables, Data Types and Primary Keys

More notes on this topic

  1. COUNT, SUM, AND and OR: Quick Revision
  2. SELECT, WHERE and ORDER BY: Quick Revision
  3. Logic Circuits and Truth Tables: Quick Revision
  4. NAND, NOR and XOR Gates: Quick Revision
  5. NOT, AND and OR Gates: Quick Revision
All notes on this topic →