Chapter 4

Database Concepts and Tables

A database stores data in tables of records (rows) and fields (columns); a primary key uniquely identifies each record.

A database is an organised collection of related data. In most databases the data is kept in one or more tables.

Records and fields

A table is a grid. Each row is a record holding all the data about one item, such as one student. Each column is a field holding one piece of data, such as Name or Age, for every record.

StudentIDNameAge
S01Aina15
S02Ben14

Here each row is a record; StudentID, Name and Age are fields.

Key idea

Row = record (one item). Column = field (one attribute). The primary key is a field whose value is unique for every record, so no two records can share it.

The primary key

A primary key uniquely identifies each record. In the table above, StudentID is a good primary key because every student has a different ID. Name would be a poor key, because two students could share a name. When you search for one record, the primary key lets the database find exactly the right row with no confusion.

Storing data in tables like this has clear benefits over a plain list: the same data is not repeated, records are easy to search and sort, and each field can hold a fixed data type such as text for Name or a number for Age. This keeps the data neat and reliable.

Remember

  • A record is a row; a field is a column.
  • A primary key is unique and cannot repeat.
  • A primary key value should not be left empty.

Stuck on this topic? A verified JomKelas tutor can walk you through it.

Find a verified tutor