Databases

Table

Databases are made up of tables. A table has columns called fields and rows called records. In IGCSE, databases only consist of a single table.

  • Fields are the different categories in a table which organise data belonging to the same group
  • Records are groups of data that often have a unique identifier
  • Validation is used to set rules for fields
🤔
A table may have a header row to display the name of each field. A header row is not a record.

Data Types

Similar to programming, databases also have data types to enforce consistency and prevent errors. Different information can require different data types. It is important to be efficient and account for all possibilities when selecting a data type for a field.

Type Example
Text & AlphanumericNames, Phone Numbers
CharacterGender
BooleanTrue & False
IntegerPopulation
RealMoney
Date & TimeDate of Birth

Phone numbers are always a text field and not a numeric field!

Primary Key

A primary key is a field in a table that acts as a unique identifier for a record. For example, a number plate can be used to uniquely identify a car. Primary keys often have a specific format and are mostly named along the lines of ID.

SQL

SQL stands for Structured Query Language. It is used to fetch information from a database. Just like most programming languages, SQL has keywords. In IGCSE, only 6 keywords are used.

  • SELECT: chooses which fields to display (* means all fields)
  • FROM: points to the name of the table where the data can be found
  • WHERE: filters records using conditions
  • ORDER BY: sorts records in ascending order by default
  • SUM: calculates the total a field
  • COUNT: counts the number of records
SELECT field_1, field_2
FROM my_table
WHERE field_1 > 0 AND field_2 = "YES";