You are on page 1of 12

IGCSE ICT 0983

Databases
Types of Data

The main types of data found in a computer system are:


Boolean Data

Boolean data types only have one of two values: True or False
Examples:
Yes or No 1 or 0 On or Off
Alphanumeric/Text Data

1- Text Data

Text data refers to the data that is made up of letters only.

Example:

The password ‘WHITE’ contains letters only and is therefore text.

2- Alphanumeric Data

Alphanumeric data refers to the data that is made up of a combination of letters AND
numbers.

Example:
The password ‘MIKE62’ contains letters and numbers and is therefore alphanumeric.

Note:

Other symbols such as @, $, # and spaces etc, are also regarded as alphanumeric data.

Examples of Text Examples of Alphanumeric


DOG DOG123
CAT “A little mouse”
Sunshine SR67JH8
House 22 Alexandria ST. Egypt
Ahmed Ahmed@gmail.com
Peter 50 Pounds

Note:

The above examples show you the true meaning of Text and Alphanumeric values.
However, in most applications, Text data types will also handle Alphanumeric data.

1
IGCSE ICT 0983

Numeric Data

Numeric data can be in two forms:


 Integer - (Whole numbers only, it can be positive or negative)
 Real - (Numbers with or without decimals, it can be positive or negative)
Examples of Integers and Real Numbers:

Integers Use Real Use


13 Number of floors in a hotel 1.87 Exact height of a person in metres
20 Number of students in a 2.56 Price of an item
26 classof a person
Age 27.3 Temperature in degrees

Q: Why does the computer need to know if the number is integer or real?
A: Because real numbers take up more space. If a database file has a million records, this can
represent a lot of wasted space.
Q: Why telephone Numbers are not numeric?
A: Because they often contain leading zeros (e.g 002)
Currency Numbers

 Currency are Real Numbers (decimals) that are formatted to include money symbols (£, $
etc).
 Currency values are usually shown with 2 decimal places.
 Currency values can be positive and negative
Examples:

£12.45
-£0.01
€999.00
$5500
Percentage Numbers

Percentage refers to fractional real numbers that are formatted in a specific way - out of 100, with
a percent symbol.

Examples:

100% 25% 125% -5%

Q: How 50% is stored inside the computer?


A: It is stored as a real number: 0.5, But when it is displayed it is shown formatted as a percentage

2
IGCSE ICT 0983

Date/Time Data

Date and Time data can be formatted in many forms:


Date Format:
 Long Date (20 February 2011)
 Medium Date (20-Feb-11)
 Short Date (21/02/11)
Time Format:

 Long Time hh:mm:ss (17:34:23)


 Medium Time hh:mm:ll(05:34:PM)
 Short Time hh:mm(17:34)

Questions & Answers

Data is to be stored in a structure 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:
Logical/Boolean Alphanumeric/text Numeric Date Currency

Name of field Example data Data type


Email ict@cie.org.uk Alphanumeric
Phone number 0798273232 Alphanumeric
Gender M or F Text
Country Egypt Text
Date of birth 01/10/03 Date
Years at address 4 Numeric
Price £5.75 Currency

3
IGCSE ICT 0983

Database Structure

Definition: Database - An organized sets of data on a computer.


Databases consist of
the following:
 Files
 Records
 Fields

Note:

Data is often stored in files, which consist of records, which in turn consist of fields.
Example of a Database
Our school holds lots of information about students on its database. Let’s take a look at the data we
might hold.

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.
What is a Record?

The information about an item or person.


Example:

4
IGCSE ICT 0983

What is a Field?

A field is a single item of data.


Example:
Our records contain 5 fields.
What is a Database File?

 A file is a collection of related records.


 The contents of database files are often viewed as Tables.
 Database Tables allow you to see the records all at once rather than individually.
 Our student database would look like this when viewed as a table:

5
IGCSE ICT 0983

Primary Key (Key field)

 Every record in a database needs to be uniquely identified.


 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?

Questions & Answers

Pupil records are kept on a computer in the school office. Here is a part of a file of year 12 student
records.

(a) Write down the name of the field which would be used as the key field. [1]

Exam Number
(b) Why would it be used? [1]

Because it is unique for each candidate.


(c) 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.

6
IGCSE ICT 0983

A school uses a database to store records about its students. Describe a situation where a record on
the database would need to be:
(a) Inserted [1]

When a new student joins the school.

(b) Deleted [1]

When a student leaves the school.

(c) Amended [1]

When a student changes phone number.


Types of Databases

There are 2 types of Databases:


Flat File Database Relational Database
Flat File Database

 Flat files only contain one table of data.


 Only suitable for very simple databases.

Example

Disadvantages of using flat file database:

 Data redundancy. There is often a lot of duplicate data in the table.


 Time is wasted retyping the same data.
 More data is stored than needs to be, making the whole database larger.
 Slow to retrieve information.
 When a record is deleted, a lot of data that is still useful may also be deleted.

7
IGCSE ICT 0983

Q: In the patient database below, write the field names that contain duplicate of data?
A: Doctor ID, Doctor and Room.

Relational Database

Definition: Relational Database - a database where the data is held in two or more tables with
relationships (links) established between them.

Example:

How can we know the name of each patient’s doctor if they are no longer in the Patient Table?
The Answer is to link the 2 tables using relationships.

8
IGCSE ICT 0983

What is a foreign key and what are they used for?

 A foreign key is a field of one table which is also the primary key of another.
 Foreign keys are used to provide the link (relationship) between the tables.
 In our patient database, Doctor Id is a key field in the Doctor Table but is also being used in
the Patient Table as a foreign key:

The advantages of using a relational database instead of a flat-file database are


as follows:

 Avoids data duplication, storage space is not wasted


 Quicker to add, remove, or edit data.
 Easier to maintain security.
 Faster data retrieval (because of links between tables).
 Fewer errors are likely.
Disadvantages of relational databases

 More complex than a flat file database as more tables are required
 Takes more time to set up
 More of a reduction in performance if many tables are needed
 Less robust due to broken keys and records / each table requires a key field and relationships
to other tables
 More developer expertise / personnel to run the database:
 More expensive to create a relational database
 More processing power needed for complex queries.

9
IGCSE ICT 0983

Advantages of flat file databases

 All records are stored in one place


 Easier to understand / use
 Sorting is simpler
 Filtering is simpler
 Can be used with a spreadsheet / single table DBMS
Validation

Validation is a process where data is checked to see if it satisfies certain criteria when input into a
computer, for example to see if the data falls within accepted boundaries.

Examples of validation checks:

Validation Check Description Example


Range Check Checks whether data is within given e.g: age >0 and < 120
values.
Length Check Checks if the input data contains the e.g: if field needs 6 digits,
required number of characters. inputting 5 or 7 causes error
message.
Format/ Picture Check Checks that data is in a specific e.g: dd/mm/yyyy
format.
Limit Check only one of the limits is checked. e.g: learner driver’s >=17
Invalid Character Check/ Checks that the input data does not e.g: person’s name should
Type check contain invalid characters. not contain any numbers

Boolean Check Data is either: True or False, Y or N. eg: Absent or Present


Gender: M or F
Presence Check Checks if data is actually present e.g: if no data is present, this
and has not been missed out. should give an error message
Consistency Check Checks if fields correspond with e.g: if Mr is typed, then
each other. gender must be Male.
Check digit Looks at an extra digit which is e.g: 2 digits inverted during
calculated from the digits of a input, 13597 instead of
number and then added to the end of 13579.
the number e.g: Mistyping – number is
entered incorrectly: 133398
is entered instead of 133598.
e.g: Missing numbers –
4099 is entered instead of
40996
Existency check Check if data matches the data Is the card number on the
stored in a database database?

10
IGCSE ICT 0983

Verification

Verification means to check that the data on the original source document is identical to the data
that you have entered into the system or object document.

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

Questions & Answers

A school library has a file for storing details of the books and it has a file for storing details of its
borrowers. The two files are linked using a common field.

(a) How many records are there in the book file? [1]

4 Records
(b) How many fields are there in the borrower file? [1]

5 fields
(c) What type of database do these two files form? [1]

Relational database

11
IGCSE ICT 0417

(d) Give two reasons why this type of database system is used rather than having two flat
files.[2]

 Data can be added and removed easily.


 Faster data retrieval (because of links between tables).

(e) Which field is the primary key in the Book file? [1]

Code

(f) Which field is the foreign key? [1]

Book Borrowed

(g) Which field has the data type currency? [1]

Cost

(h) What data type would be most appropriate for the Due Back field? [1]

Date

Tick whether the following statements are true or false about student records in a database. [4]

A file is a collection of related records. [True]

A field is one item of data such as name or address. [True]

The same value can occur several times within a key field. [False]

A record is the complete data about one student. [True]

12

You might also like