A record is a composite data type that groups together a fixed number of related fields, each with its own name and data type. Where an array stores many values of the same type, a record stores several values of different types that logically belong together — for example, a student's name (string), age (integer), and target grade (character).
Why do we need records?
Suppose you want to store information about a student:
name: "Alice Johnson" (string)
age: 15 (integer)
grade: "A" (character)
score: 87.5 (real)
You could store these as four separate variables, but they become difficult to manage as a group — passing them to a function, storing multiple students, or looping over them all become awkward.
A record bundles them into a single named unit. Think of it like a row in a spreadsheet: each column is a field with a heading (field name) and a type, and each row is one record containing actual values.
How is a record defined in pseudocode?
Different exam boards use slightly different syntax. OCR's pseudocode (the most commonly examined at GCSE) uses a record keyword:
record Student
name : String
age : Integer
grade : Char
score : Real
end record
Once defined, you can declare variables of that record type and access individual fields using dot notation:
student1 : Student
student1.name ← "Alice Johnson"
student1.age ← 15
student1.grade ← 'A'
student1.score ← 87.5
OUTPUT student1.name // Alice Johnson
OUTPUT student1.score // 87.5
How is a record equivalent defined in Python?
Python does not have a built-in record keyword, but the same concept is implemented using a class (the OOP way) or, more simply for basic records, using a dictionary or a dataclass:
# Using a dictionary (simplest — KS3/GCSE approach)
student1 = {
"name": "Alice Johnson",
"age": 15,
"grade": "A",
"score": 87.5
}
print(student1["name"]) # Alice Johnson
# Using a class (OOP approach)
class Student:
def __init__(self, name, age, grade, score):
self.name = name
self.age = age
self.grade = grade
self.score = score
s = Student("Alice Johnson", 15, "A", 87.5)
print(s.name) # Alice Johnson
For GCSE, the pseudocode record definition is more directly examinable; the Python dictionary is the most common equivalent used in practice at this level.
How do records differ from arrays?
| Feature | Array | Record |
|---|---|---|
| Elements | All the same data type | Different data types per field |
| Access | By integer index: array[2] |
By field name: student.age |
| Best for | A collection of similar items | A group of related but different items |
| Example | [85, 90, 72, 88] — a list of marks |
{name, age, grade, score} — one student's data |
| Size | Fixed or dynamic, depending on language | Fixed number of fields defined at design time |
An array of records combines both structures — you can create an array where every element is a student record, giving you a table of data:
students : array[0..29] of Student // 30 student records
students[0].name ← "Alice Johnson"
students[0].score ← 87.5
students[1].name ← "Ben Khan"
students[1].score ← 91.0
// Loop over all students
FOR i ← 0 TO 29
OUTPUT students[i].name, students[i].score
END FOR
This is one of the most practically useful programming patterns — it is essentially what a database table is at the algorithmic level.
How do records relate to databases and files?
In database terminology, a record is equivalent to a row in a table. The fields of the record correspond to the columns. When data is stored in a CSV (comma-separated values) file, each line typically represents one record:
Alice Johnson,15,A,87.5
Ben Khan,15,B,76.0
Carol Patel,14,A,92.3
Reading this file into a program means reading each line, splitting it by commas, and storing the values in the appropriate fields of a record. This connection between programming records and file/database records is central to real-world data processing.
Frequently asked questions
What is a record in programming for GCSE?
A record is a composite (combined) data type that groups several related pieces of information together, where each piece (called a field) can have a different data type. For example, a student record might have a string field for the name, an integer for the age, and a real number for the score. This makes it easy to pass all a student's data around the program as a single unit.
What is the difference between a record and an object in OOP?
A record simply groups data fields together — it has no behaviour (no methods). An object in object-oriented programming groups data (attributes) and behaviour (methods) together. A student record holds name, age, and score. A student object also has methods like calculateGrade() or printReport(). Records are simpler; objects are more powerful. At GCSE, records and simple classes are both examined.
How do you create an array of records in pseudocode?
Declare the record type first, then declare an array where each element is of that record type: students : array[0..29] of Student. Access an individual field using both the array index and the field name: students[5].name. This creates a two-dimensional, mixed-type data structure similar to a spreadsheet or database table.
Why are records useful in programming?
Records make code more readable and maintainable by grouping related data logically. Instead of managing four separate variables for each student (name, age, grade, score), you manage one student record. When you create an array of records, you can loop over all students and access any field by name, making operations like sorting, searching, and printing much more natural to write.
Practice writing and tracing records in pseudocode with Professor Turing at aitutors.me — questions guide you to the answer, not lectures that give it away.