Records
Computer ScienceΒ· Unit 10 Data types & structures, 10.3 RecordsΒ· 15 min read
1. 1. What is a Record?β β ββββ± 3 min
Record (Composite Data Type)
A fixed collection of related data items (called fields) that can be of different data types, used to represent attributes of a single real-world or abstract entity.
Example:
A Student record could have fields for name (string), age (integer), and enrolment status (boolean).
Unlike arrays, which store multiple values of the same type accessed by index, records group heterogeneous data where each field is identified by a unique name. This makes records ideal for modeling structured objects with multiple distinct attributes.
Identify which of the following is best represented as a single record: (A) A list of 100 test scores, (B) The details of a single customer order, (C) A table of 50 employee entries
- 1
Recall that a single record describes one entity with multiple attributes. Check each option:
- 2
Option A: All test scores are integers of the same type β best stored as an array, not a single record.
- 3
Option B: A customer order has multiple attributes of different types: order ID (integer), customer name (string), total cost (float) β matches the definition of a single record.
- 4
Option C: 50 employee entries β each employee is a record, so this is an array of records, not a single record.
- 5
Final answer: B
2. 2. Declaring Records in CIE Pseudocodeβ β β βββ± 4 min
Record Declaration
The process of defining a new record type's structure, including the name and data type of each field. Once declared, the record type can be used to create individual instances.
CIE exams follow a standard pseudocode format for declaring records, which you must use to get full marks. The general format is:
Declare a new record type called Movie with fields: title (string), release year (integer), rating (real), is_available (boolean). Then create an instance called myMovie.
- 1
Start the record declaration:
- 2
- 3
Declare each field with its data type:
- 4
- 5
Close the declaration and instantiate the record:
- 6
3. 3. Accessing and Modifying Record Fieldsβ β ββββ± 3 min
Fields in a record are accessed using dot notation, which is standard across CIE pseudocode and most programming languages. The format is: \textit{<record_instance>}.\textit{<field_name>}. This notation works for both reading field values and assigning new values.
Using the Movie record type from the previous section, assign values to myMovie and output the title and release year.
- 1
Assign values to each field using dot notation:
- 2
- 3
Read the field values and output them:
- 4
- 5
The final output will be:
Inception (2010)
Test your understanding of dot notation:
What is the correct way to output the rating of the
myMovieinstance?OUTPUT Movie.rating
OUTPUT myMovie(rating)
OUTPUT myMovie.rating
OUTPUT rating.myMovie
Reveal answer
2 βCorrect! Dot notation follows the order
instance_name.field_name, you cannot use the record type name to access a field.
4. 4. Arrays of Recordsβ β β βββ± 5 min
The most common use of records in CIE exams is storing multiple entities of the same type as an array of records. This combines the benefits of arrays (simple iteration over elements) with records (storing heterogeneous attributes per entity). For example, you can store 100 movie entries as an array where each element is a Movie record.
Declare an array of 20 Movie records called cinemaCollection, then output the title of every movie with a rating higher than 8.0.
- 1
Declare the array after defining the
Movierecord type: - 2
- 3
Loop through each element, check the rating field, and output matching titles:
- 4
- 5
This loop correctly checks each record in the array and outputs only titles that meet the condition.
5. Common Pitfalls
Wrong move:
Confusing record type with record instance when accessing fields.
Why:
The record type is just a template, only instances store actual data values.
Correct move:
Always use instanceName.fieldName, not typeName.fieldName.
Wrong move:
Forgetting to close a record declaration with END RECORD.
Why:
CIE mark schemes require explicit closing of RECORD blocks to award full marks.
Correct move:
Always add END RECORD after declaring all fields of a record.
Wrong move:
Incorrect dot notation order for fields in arrays of records.
Why:
Students often write arrayName.fieldName[index] instead of the correct order.
Correct move:
Index the array first, then access the field: arrayName[index].fieldName.
Wrong move:
Using a single record to store multiple entities.
Why:
A record is designed to describe one entity. Storing multiple entities in one record makes iteration impossible.
Correct move:
Use an array of records: one record per entity, stored as elements in the array.
6. Quick Reference Cheatsheet
Concept | CIE Pseudocode Format |
|---|---|
Declare record type | DECLARE <Name> RECORD |
Declare record instance | DECLARE <InstanceName>: <RecordName> |
Access record field | <Instance>.<FieldName> |
Declare array of records | DECLARE <ArrayName>: ARRAY[<low>:<high>] OF <RecordName> |
Access field in array of records | <ArrayName>[<index>].<FieldName> |
7. Frequently Asked
What is the difference between a record and an array?
An array stores multiple elements of the same data type accessed by index, while a record stores multiple related values of different data types that describe a single entity. Fields in a record are accessed by name, not index.
When this came up on past exams
AI-estimated based on syllabus patterns β cross-check with official past papers for accuracy. Use only as revision-focus signals.
- 2022 Β· 12
Declare record for library books
- 2023 Β· 11
Process array of student records
- 2021 Β· 13
Access nested record fields
Going deeper
What's Next
Records are a foundational composite data type that you will use extensively in both Paper 1 problem solving and Paper 2 programming tasks for CIE A-Level Computer Science. Mastering record declaration and field access is critical for handling structured real-world data, and it builds the foundation for understanding more advanced data structures like linked lists, classes, and relational database entries. You will often encounter records paired with file handling, where you read and write records to text or binary files to store persistent data. Understanding how to iterate over arrays of records is also a common requirement for implementing sorting and searching algorithms, which are core exam topics.
- βLinked Lists
- βStacks
- βQueues
