Professional Documents
Culture Documents
Chapter 09
Databases
Created by:
Mr. Mahmoud Moussa
01098569912
www.mahmoudmoussa.com
Types of Data
The main types of data found in a computer system are:
4
Example
Data is to be stored in a database and to do this a data type must be chosen for each
item of data. Choose a suitable data type from the following list for the data shown in
the table:
Boolean Alphanumeric/text Character
Integer Date Real
Records
Fields Record 1 Record 2 Record 3
F F F F F F F F F
Structure of a database
Note:
Data is often stored in files, which consist of records,
which in turn consist of fields. 6
Example of a Database
Our school holds lots of information about students on its database.
Lets take a look at the data we might hold.
Cand No.: 8209 Cand No.: 8211 Cand No.: 8215 Cand No.: 8220
Name: Heba Name: Ahmed Name: Roaa Name: Abbas
D.O.B: 3 Mar 1995 D.O.B: 3 Apr 1995 D.O.B: 3Jun1995 D.O.B: 3Aug1995
Phone: 3916203 Phone: 3716206 Phone: 3816209 Phone: 3516207
Grade: 10 PC Grade: 10 QE Grade: 10 PC Grade: 10 QE
Notice how each student has similar information stored about them. For example,
Name and D.o.B. We want to store this information in an organised way so that we can
access it easily. In other words we want a database. 7
Database Records & Fields
What is a Record?
The information about an item or person.
Example:
Cand No.: 8209 Cand No.: 8211 Cand No.: 8215 Cand No.: 8220
Record 1
Record 2
Record 3
Record 4
Name: Heba Name: Ahmed Name: Roaa Name: Abbas
D.O.B: 3 Mar 1995 D.O.B: 3 Apr 1995 D.O.B: 3Jun1995 D.O.B: 3Aug1995
Phone: 3916203 Phone: 3716206 Phone: 3816209 Phone: 3516207
Grade: 10 PC Grade: 10 QE Grade: 10 PC Grade: 10 QE
What is a Field?
A field is a single item of data.
Field 1
Example: Cand No.: 8209 Field 2
Name: Heba
Our records contain 5 fields. D.O.B: 3 Mar 1995 Field 3
Phone: 3916203
Grade: 10 PC Field 4
8
Field 5
Database Files
What is a Database File?
A file is a collection of related records.
Our student database would look like this when viewed as a table:
9
Database Files
CandNo Name DOB Phone Grade
8209 Heba 3 Mar 1995 3916203 10 PC
Each row
8211 Ahmed 3 Apr 1995 3716206 10 QE in a table
8215 Roaa 3Jun1995 3816209 10 PC contains a
8220 Abbas 3Aug1995 3516207 10 QE
record.
Each
CandNo Name DOB Phone Grade column in
8209 Heba 3 Mar 1995 3916203 10 PC a table
represents
8211 Ahmed 3 Apr 1995 3716206 10 QE
a field.
8215 Roaa 3Jun1995 3816209 10 PC
8220 Abbas 3Aug1995 3516207 10 QE
Unique data makes sure that when we are accessing a record, we are accessing
the right one
Take another look at our student database. Which item of data uniquely
identifies students from each other?
Name Cand No
A key field is a piece of data in a database
D.O.B Grade that is unique to a particular record. 11
Example
Pupil records are kept on a computer in the school office. Here is a part of a file
of year 12 student records.
Write down the name of the field which would be used as the key field. [1]
ExamNumber
Why would it be used? [1]
Because it is unique for each candidate.
Why is it more suitable to use date of birth rather than age? [1]
Age for each student changes every year and so database file will need to be
continually updated. 12
Validation
Validation
Range Check
Checks whether data is within given values.
e.g: age > 0 and < 120
Length Check
Checks if the input data contains the required number of characters.
e.g: if field needs 6 digits, inputting 5 or 7 causes error message.
Validation
Examples of validation checks:
Type Check
Checks that the input data does not contain invalid characters.
Presence Check
Checks if data is actually present and has not been missed out.
e.g: if no data is present, this should give an error message
Consistency Check
Checks if fields correspond with each other.
e.g: if Mr is typed, then gender must be Male.
Error Checking Methods
Examples of validation checks:
Check digit
How a check digit can be used to make sure the data entered is correct?
Bar codes
Example: 280419 becomes 250419 (one of the digits has been mistyped)
17
Verification
Verification
There are two ways that verification checks are carried out:
Double Data Entry
Data is typed in twice by one typist or data is typed in by two operators and
computer compares versions
If different freezes/sounds buzzer.
Visual check
This is the checking for errors by comparing entered data on the screen
with the data in the original document