Files, Records, Fields & Key Fields
For this, we shall use the example of a school database, keeping data about the students. The FULL set of data about ALL the students is called the FILE. There may be a file for the data about the teachers as well.
The student file is split into sets of data about each individual student. These sets of data are called RECORDS. Each student will have their OWN record.
The record could contain many pieces of data Eg. Name, Form Tutor, Gender, No. in family. Each of these pieces of data is called and ITEM OF DATA and they are stored in FIELDS. Each record must have the same fields.
Each RECORD in the file must be distinguishable from other records. If there were two people with the same name, you wouldn't know which data belongs to who.
So a KEY FIELD is used. This is unique and will usually be a number. a key field is sometimes called a PRIMARY KEY.
A file is a group of records. A record is a group of fields. And a field contains a single item of data.
Types of File
In a SERIAL file, the records are not stored in any particular ORDER.
In a SEQUENTIAL file, the records are stored in order of KEY FIELD.
In a DIRECT ACCESS file, the records arev stored on a DISK using an INDEX.
SERIAL files take a VERY LONG time to locate an individual record.
DIRECT ACCESS files are the QUICKEST to find an individual record.
There are three types of file maintenance:
- Updates or ammendments to a record. (Eg. Form tutors change forms every year)
- Insertions to a file. (Eg. A new student arrives)
- Deletions to a file. (Eg. A student leaves)
In a database, each field is assigned a DATA TYPE. The data entered must fit this data type.
There are two types of NUMERIC DATA:
- INTEGERS: Whole numbers (16, 46563) Eg. 7 people, 5 cars
- REAL NUMBERS: Numbers with a decimal part (16.5, 567.88) Eg. a person's height. They require more storage space than integers
DATE data type: Takes the form 3 pairs of numbersseparated by slashes (14/04/13) Can have last set as 4 numbers but this takes more stporage space (14/04/2013)
ALPHANUMERIC data type: Contains characters and text.
BOOLEAN data type: Where data is one of two characters. Eg. Y / N for yes / no
CURRENCY: A real number data type. Must have two digits after decimal point.
Checking Data Entry
DATA VALIDATION is when the software checks input data for errors. They use checks:
A LENGTH CHECK counts the number of charcters entered. Eg for a date of format DD/MM/YYYY, 14/4/2013 would not be accepted as there must be 10 characters (including slahes.)
A CHARACTER CHECK checks the right sort of characters are being entered. Eg using a date such as 14/APRIL/2013 would not be accepted as digits should be used not letters.
A FORMAT CHECK checks the data is being entered in the right 'pattern.' Eg 14/2013/04 would not be accepted as the system is excpecting DD/MM/YYYY
A PRESENCE CHECK checks some data has been entered. Eg. if no DOB was entered the system would report an error.
However, even with these checks data can still be wrong. Eg. accidentaly putting a DOB in the format MM/DD/YYYY instead of DD/MM/YYYY. The checks could pass this so sometimes you are asked to input data TWICE. This is called DATA VERIFICATION.
Flat File and Relational Databases
A FLAT FILE DATABASE contains many tables (files) which are not connected together.
In a database, you may want to link certain files / tables together to form a RELATIONAL DATABASE.
This can be done by using a FOREIGN KEY.
Remember a PRIMARY KEY is a field used in a file so each record can be identified uniquely from other records.
A FOREIGN KEY is a field in one table that is also the PRIMARY KEY in another one. This foreign key links the tables together.
Eg. Imagine a relational database with two tables. One conatins: student id, student name and gender, whilst the other contains, A level subject chosen and student id.
The student id would be the foreign key as it is the primary key in the first table but also used in the other table.
Analogue & Digital Data
ANALOGUE DATA is data that can have ANY value within a given range. It is continuously varying.
DIGITAL DATA is known as discrete data. It has FIXED values in a given range. Any changes occur in discrete steps.
A computer can only use data in a DIGITAL FORMAT. This means analogue measurements (Eg. Light, temperature) must be converted into DIGITAL DATA by an ANALOGUE-TO-DIGITAL CONVERTER (ADC)
Similarly, computers can't control analogue devcies directly. Their DIGITAL DATA must be converted into ANALOGUE DATA by a DIGITAL-TO-ANALOGUE CONVERTER (DAC.) An example of a DAC is a SPEAKER.