There are 2 main types of data structure
Arrays &
Records
An Array is
"a set of data items of the same type grouped together using a single identifier".
A Field
is an individual piece of information.
A Record
is all the info (fields) about an entity (or thing)
A File.
All of the records together make up a file of information.
A Database
is a collection of related files
A Primary key.
A unique piece of data to ID a record.
Arrays and their Use
If you need to store 10 exam results, the computer decides which addresses to use to store the data in.
It could decide to use 10 memory addresses that are spread out from each other.
The user doesn't know what actual addresses have been selected and they don't need to know.
But, they will need to be able to fetch each of the pieces of data from time to time,
by giving each piece of data a name.
To store 1000 results we would also need to store 1000 variable
It might be better to group similar types of data together in a table giving the array a single name.
Then, if you wanted any particular piece of data (an element),
you can refer to the name of the array along with the co-ordinates of that element
•To use an array, it must be initialised in the program
•This forces the computer to group together the array data in a block of successive memory locations.
To set up an array in a program declare:
The name (the identifier) of the array.
The size of the array
The data type the array will hold
BOUNDS: The Lowest and Highest values of the Index
INDEX: The position of the data in the array (used to reference
ELEMENTS: The values of the data in each positiion
In the above example (1 & 4)
Scores: array[1..10] of integer
(This array will store 10 scores)
Addressing elements in a one-dimensional array
In an array, you refer to a particular place in the array by using
the array's identifier (it's name)
followed by an 'address'.
Example, to define a one-dimensional array called SCORES that can hold up to 10 integers,
you would use something like this:
SCORES: array[1..10] of integer
Addressing elements in a one-dimensional array
To define a two-dimensional array called RECORD_OF_SCORES to stores 10 pupils' last three scores.
You would use something like this:
RECORD_OF_SCORES: array [1..10,1..3] of Integer