Records in Software Design and Development are different to records used within the ISDD unit. It is important to be able to explain the purpose of records in each context.

In Software Design and Development, a record is a programmer-defined data type.

1-D arrays can only store data of the same data type.

It is not possible to use a 1-D array to store multiple data types at the same time.

If you want to hold related data of different data types it is practical to use a record type.

Why use records?

To store information on Scottish cities, namely the city name, population, area in km and whether or not it was the capital city, we could use four separate arrays to store each set of data:

  • one array for the city name
  • one array for the population
  • one array for the area in km
  • one array for whether or not the city was the capital

This is known as using parallel arrays.

Alternatively, a record structure could be used. This would allow the data for each city to be scored together, rather than in four different arrays.

A record type to store information on each city would look like this when created using reference language:

RECORD cityData IS {STRING cityName, INTEGER population, INTEGER area km, BOOLEAN capital}

The line shown above creates a template for how a record type would be stored, it is not yet populated with any values.

Individual variables for each city could be declared and initialised as follows:

DECLARE Glasgow INITIALLY CityData ( “Glasgow” , 596550, 176, FALSE )

DECLARE Dundee INTIALLY CityData ( “Dundee”, 147285, 67, FALSE )

DECLARE Perth INTIALLY CityData ( “Perth”, 46970, 21, FALSE )

DECLARE Aberdeen INTIALLY CityData ( “Aberdeen”, 220420, 186, FALSE )

DECLARE Stirling INTIALLY CityData ( “Stirling”, 36142, 105, FALSE )

DECLARE Edinburgh INTIALLY CityData ( “Edinburgh”, 487500, 264, TRUE )

DECLARE Inverness INTIALLY CityData ( “Inverness”, 48201, 36, FALSE )