BETAThis platform is under active development; bugs, missing features, and risk of data loss are present. Thank you for your support!

Databases

Learn it by playing

Answer these questions to earn energy, then fish and explore. No account needed.

For teachers: ready-to-use lesson slides, revision notes, diagrams for Databases (Computer Science, CIE) — use them in your lesson, or run the topic as a live class game.

Notes

What is a Database?

  • A **database** is an organised collection of data.
  • It consists of one or more **tables** made up of **fields** and **records**.
  • Databases allow easy storage, retrieval, and management of information.
  • They are stored on **secondary storage** and often on remote servers for multi-user access.
  • Data can be sorted and searched efficiently, and databases are more secure than text files.

Fields & Records

  • A **field** is one piece of information relating to one person/item/object; represented as a **column**.
  • A **record** is a collection of fields relating to one person/item/object; represented as a **row**.
  • Example: In a student table, fields include StudentID, FirstName, LastName; each row is a record.

Text Files vs Databases

  • **Text files** are useful for small amounts of data; stored on secondary storage and read into a program.
  • Each entry is stored on a new line or separated by a delimiter (e.g., comma).
  • It can be difficult to know where a record begins and ends in a text file.
  • Databases provide better structure, security, and efficiency for large data.

Data Types

  • A **data type** defines the type of data held in a field, set when designing a table.
  • Common data types: **Integer** (whole number), **Real** (decimal), **Text/alphanumeric**, **Character** (single), **Date/Time**, **Boolean** (true/false).
  • Example: In a cars table, carid is Integer, make is Text, price is Real.

Validation Checks

  • **Validation rules** control what data can be entered into a field.
  • **Length check**: ensures a fixed number of characters (e.g., phone number 11 digits).
  • **Format check**: ensures data matches a pattern (e.g., two letters + five numbers).
  • **Range check**: ensures a number is within a range (e.g., age 0–40).
  • **Presence check**: ensures a field cannot be left blank.
  • **Type check**: ensures data is of the correct data type (e.g., date field cannot have text).
  • **Check digit**: a digit added to a number to verify accuracy using an algorithm.

Primary Keys

  • A **primary key** is a unique field that identifies each record in a table.
  • It must be unique for every record and cannot be null.
  • Examples: CustomerID, StudentID, Car Registration, ProductID.
  • Primary keys are often ID numbers (e.g., MemberID in a Members table).

Key Database Terminology

  • **Table**: a collection of records with a similar structure.
  • **Record**: a group of related fields representing one data entry (a row).
  • **Field**: a single piece of data in a record (a column).
  • **Data type**: the type of data held in a field.
  • **Primary key**: a unique identifier for each record, usually an ID number.

Structure of a database table showing fields (columns) and records (rows). The primary key uniquely identifies each record.

Database Table StructurefieldrecordField (column)Record (row)Primary KeyArt: bioicons.com

Practice questions

Free preview — 8 of 39 questions. Sign up to see them all.

  1. 1.What is a database?

    Easy
    • AAn organised collection of data
    • BA collection of text files
    • CA single table of data
    • DA program for editing data
  2. 2.In a database table, a field is represented by a:

    Easy
    • ARow
    • BColumn
    • CRecord
    • DTable
  3. 3.In a database table, a record is represented by a:

    Easy
    • AColumn
    • BField
    • CRow
    • DPrimary key
  4. 4.Which of the following is the most suitable primary key for a table storing information about books in a library?

    Medium
    • AAuthor
    • BTitle
    • CISBN
    • DPublisher
  5. 5.Which validation check would ensure that a phone number field contains exactly 11 digits?

    Medium
    • ARange check
    • BLength check
    • CFormat check
    • DPresence check
  6. 6.A product code must be two letters followed by five numbers. Which validation check should be applied?

    Medium
    • ALength check
    • BRange check
    • CFormat check
    • DType check
  7. 7.Which data type would be most appropriate for a field storing a person's date of birth?

    Medium
    • AInteger
    • BText
    • CDate/Time
    • DBoolean
  8. 8.A field is defined as 'Boolean'. What type of values can it store?

    Medium
    • AWhole numbers only
    • BDecimal numbers
    • CTrue or false values
    • DSingle characters

Unlock all 39 questions, slides & more

Create a free account to see every question, the slides, flashcards and revision notes for this topic.

Past papers

Past-paper practice for this topic is coming soon.

🗂️ Coming soon