You are on page 1of 25

Head to savemyexams.

com for more awesome resources

IGCSE ICT CIE Your notes

14.1 Databases
Contents
Types of Database
Primary & Foreign Keys
Form Design
Perform Calculations
Sort Data in Databases
Search & Select Data in Databases
Present Data

Page 1 of 25

© 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to savemyexams.com for more awesome resources

Types of Database
Your notes
Flat File Database & Relational Database
A database is a structured collection of data so it can be searched, sorted,
filtered and analysed quickly
Data in a database can be any type of data including text, images, videos, sound
Databases use tables to store data
Tables have records of data represented by one row
In the example below, each row represents the data stored about a single customer (the
customer’s record)
In the customer table, there are 3 records
Each record is divided into fields (CustomerID, FirstName, LastName, DOB and Phone
Number)
A Database Table Containing Customer Details

CustomerID FirstName LastName DOB PhoneNumber

1 Andrea Bycroft 05031976 0746762883

2 Melissa Langler 22012001 0756372892

3 Amy George 22111988 0746372821

Fields are represented by the columns in a table


There are 5 fields in the customer table
The first row in a table contains the field names which is the heading for the data stored in that
field
Each field in a table has a data type which defines what data can be entered into that field

Flat File Database Relational Database

A single table of data


Characteristics Organises data into multiple tables
Data separated by commas or
Tables linked by primary and foreign keys
tabs

Page 2 of 25

© 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to savemyexams.com for more awesome resources

Flat File Database Relational Database


Your notes

Suitable for large datasets


Uses Ideal for small datasets
Used in sectors such as healthcare and
Used in data import/export
finance

Reduced data redundancy due to


normalisation
All records are stored in one Reduced inconsistency of data
place Easier to edit records/record format
Advantages Easier to use Easier to add/delete data/records
Sorting and filtering are simpler More complex queries can be carried out
Can be used with a spreadsheet Better security
More ability to cater for future
requirements

Complex to set up and manage costing


Data redundancy with time and money
duplicated data Requires more processing power
Difficult to manage as database compared to flat file databases
siz e grows Slower extraction of meaning from data
Harder to update Less robust as each table requires a key
Disadvantages
Harder to change the data field
format and relationships to other tables
Harder to produce complex More developer expertise to run the
queries database
Almost no security More processing power is needed for
complex queries

Page 3 of 25

© 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to savemyexams.com for more awesome resources

Worked example
Your notes
The owner of a gardening company is planning to create a database to store the details of all his
customers. He has the choice of using a flat file database or a relational database.
Discuss the advantages and disadvantages of using a relational database rather than a flat file
database.
[8]
Advantages of relational databases
Less data entry/data is stored only once / avoids duplication of data
Less inconsistency in data
Easier to edit data/records
Easier to edit data/record format
Easier to add/delete data/records
More complex queries can be carried out
Better security
More ability to cater for future requirements/expansion
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
Slower extraction of meaning from data
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 is needed for complex queries.
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
Disadvantages of a flat file database
Data is more likely to be duplicated / difficult to stop duplication
Records can be duplicated and the flat file will not stop this

Page 4 of 25

© 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to savemyexams.com for more awesome resources

Harder to update
Every record in the database has to have the same fields, even though many are not used
Harder to change the data format Your notes
Harder to produce complex queries
Almost no security

Page 5 of 25

© 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to savemyexams.com for more awesome resources

Data Types
Import Data and Create Tables Your notes
You can import data from existing files, like .csv or .txt
You can use specified field names to create tables

Data Types
Each field in a table has a data type
If you assigned the data type Integer to a phone number it would remove the initial 0
Common data types include text/alphanumeric, character, boolean,
integer, real and date/time
Phone numbers have to be assigned the text/alphanumeric data type because they begin
with a 0
Database Data Types

Data Type Explanation Example

This data type allows letters, special characters like spaces and
Text/Alphanumeric NG321AE
punctuation and numbers to be entered into a field

This allows single characters to be entered into a field. Characters can


Character A
be any alphanumeric value and can be lowercase or uppercase

This data type can be used in fields where there are only two possible
Boolean options. Data is stored as a 1 or 0 in the database but can be used to True/False
represent True/False or Yes/No or checked/unchecked

Integer Only whole numbers can be entered 15

Currency Used for monetary values £4.75

Decimal / Real Numbers including decimal numbers can be stored 30.99

Page 6 of 25

© 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to savemyexams.com for more awesome resources

Only dates or times can be entered into a field with this type. A format
Date/Time 180855
for the date/time can also be assigned to the field Your notes

Setting Data Types and Sub-Types


You can set appropriate data types to fields
You can set sub-types of numeric data including percentages, the number of decimal places
Setting Display Formats
You can set the display format of Boolean/logical fields to either
Yes/No
True/False
Checkbox
You can set the display format of date/time data

Exam Tip
Make sure you're specific which type of numeric data it should be - integer, decimal/real or
currency

Page 7 of 25

© 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to savemyexams.com for more awesome resources

Worked example
Your notes
A farmer has purchased a computerised milking system for her cows. She has asked a systems
analyst to create a database to store details of the cows being milked.
Examples of the details of the cows which will be stored are:

Breed Date_of_birth Weight_of_cow Average_milk_yield Passport_number

Holstein 25/02/2017 725.9 24.5 998/2017


Ayrshire 15/03/2016 715.0 20.1 972/2016
Jersey 25/02/2017 732.7 25.0 971/2016
Holstein 10/10/2016 715.0 25.0 765/2016

Complete the following table by entering the most appropriate data type for each field. For any
numeric field, specify the type of number.

Field name Data type

Breed
Date_of_birth
Weight_of_cow
Average_milk_yield
Passport_number
[5]

Field name Data type

Breed Text [1]


Date_of_birth Date [1]
Weight_of_cow Numeric: decimal/real [1]
Average_milk_yield Numeric: decimal/real [1]
Passport_number Text [1]

Page 8 of 25

© 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to savemyexams.com for more awesome resources

Primary & Foreign Keys


Your notes
Primary Keys & Foreign Keys
What is a Primary Key?
Each table has a primary key field which acts as a unique identifier
Each item of data in this field is unique
Duplicate data items would be blocked if they were entered into the primary key field
Because the items of data are unique within the primary key field they can be used to identify
individual records
A Database Table Containing Customer Details

CustomerID FirstName LastName DOB PhoneNumber

1 Andrea Bycroft 05031976 0746762883

2 Melissa Langler 22012001 0756372892

3 Amy George 22111988 0746372821

In the example customer table, the primary key would be the CustomerID because each
customer’s ID is unique
If there was a customer with the same name they could be identified correctly using the
CustomerID
Creating and Editing Keys
Primary key - Uniquely identifies each record in a table
Foreign key - Used to link two tables together. The Foreign Key in one table would be the primary
key in another

Page 9 of 25

© 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to savemyexams.com for more awesome resources

Your notes

Creating Relationships Between Tables


Relational databases allow you to create relationships between different tables using primary
and foreign keys

Page 10 of 25

© 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to savemyexams.com for more awesome resources

Your notes

What is a Foreign Key?


A foreign key is how we link tables together using primary keys
Using the table above with customer details, we'll add another table showing subscriptions that
customers have
In this example CustomerID is a foreign key as it links with the CustomerID in the customer table
above

SubscriptionID CustomerID SubscriptionType

1 2 Annual
2 1 Monthly
3 3 Quarterly

Page 11 of 25

© 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to savemyexams.com for more awesome resources

Exam Tip
Your notes
If the answer to a question is the name of a field, ensure you copy it exactly from the
question. The examiner is looking for an exact answer with the correct capital letters and
underscores where they're included

Worked example
A systems analyst has created a new computer system to keep records in a medical centre. She
has created a relational database to store the medical records of patients.
The database uses primary and foreign keys. Explain the difference between a primary key and a
foreign key.
[4]
4 of:
The primary key holds unique data [1]
The primary key identifies the record [1]
The primary key can be automatically indexed [1]
Each table has one primary key whereas a table can contain several foreign keys [1]
A foreign key is used to link with the primary key of another table [1]

Page 12 of 25

© 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to savemyexams.com for more awesome resources

Form Design
Your notes
Form Design
Characteristics of Good Form Design
Simplicity - The design should be clean and straightforward, not cluttered
Ease of use - Users should be able to understand how to fill out the form quickly
Intuitive layout - Related fields should be grouped together, and the sequence of fields should
follow a logical order
Clear labels - Each field should have a clear, concise label indicating what information is
expected
Appropriate controls - Use controls like radio buttons, checkboxes, and drop-down menus
where appropriate
Creating a Data Entry Form
You need to specify the fields required for data input
Choose the appropriate font styles and siz es. Aim for consistency and readability
Keep adequate spacing between fields for clarity and ease of use

Fine-Tuning Form Design

Page 13 of 25

© 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to savemyexams.com for more awesome resources

Appropriate Spacing
The spacing between individual characters in fields should be adjusted for readability Your notes
The use of white space is crucial - it improves readability and reduces cognitive load
Control Elements
Radio Buttons - Used when there is a list of two or more options that are mutually exclusive
Check Boxes - Used when the user can select multiple options from a list
Drop Down Menus - Used when you want to provide many options but conserve space

Exam Tip
Always focus on simplicity and user-friendliness in form design
Make sure your form uses clear labels, logical field grouping, and intuitive sequence

Page 14 of 25

© 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to savemyexams.com for more awesome resources

Worked example
Your notes
A school is setting up a new computerised system to manage many aspects of the school
administration. The data from the registration system is saved in the school administration
database. The headteacher will need to check the attendance records for any student for any
semester. She will type in the Student_ID and the Semester (Autumn, Spring or Summer). After she
has done this the following data will appear on the same screen.

Field name

Student_name
Days_present
Number_of_lates
Number_absences
Parents_phone_number
Tutor_group

Design a suitable screen layout to display one record. It must have appropriate spacing for each
field, navigation aids and a space to type in search data. Do not include examples of students.
[6]
4 of:
Appropriate spacing for each field [1]
Forward/backward buttons [1]
Submit/search button [1]
Information attempts to fill the page AND the design looks appropriate to scenario [1]
Box/boxes to enter Semester or Student_ID [1]
Drop down for the Semester or Student_ID // radio button for semester [1]
Suitable title [1]
Instructions/help [1]
2 marks for all six fields
1 mark for three to five fields
0 marks for less than three fields

Page 15 of 25

© 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to savemyexams.com for more awesome resources

Perform Calculations
Your notes
Perform Calculations
Use of Arithmetic Operations or Numeric Functions
In a database, you can use arithmetic operations or numeric functions to perform calculations
Calculated Fields are fields that carry out a calculation based on other number fields in the
database
Let's say you have a products table with Price and Quantity fields. You could create a TotalCost a
calculated field like this:
TotalCost = Price * Quantity
This calculation multiplies the price of each item by its quantity to find the total cost
Calculated Controls are objects you place on forms or reports to display the result of an
expression
You might have a form in a sales database where you input the QuantitySold and UnitPrice. A
calculated control could be used to display the TotalSale:
TotalSale = QuantitySold * UnitPrice
This displays the total sale on the form without storing it in the database
Using Formulae and Functions to Perform Calculations
Databases allow you to use formulae and functions to perform calculations at run time
This can include basic arithmetic operations: addition, subtraction, multiplication, and division
Suppose you have a discount field and you want to subtract it from the total cost, you could use
a subtraction operation like this:
FinalCost = TotalCost - Discount
Aggregate Functions
You can also use aggregate functions to calculate statistical information about a set of records.
Some examples include:
Sum - Adds together all the numbers in a column
To find the total cost of all products sold, you could use the SUM function on the TotalCost
field:
SUM(TotalCost)
Average - Computes the average of a set of numbers in a column
To find the average price of all products, you could use the AVERAGE function:
AVERAGE(Price)
Maximum - Finds the highest number in a column
To find the most expensive product, you could use the MAX function on the Price field:
MAX(Price)
Minimum - Finds the lowest number in a column

Page 16 of 25

© 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to savemyexams.com for more awesome resources

To find the least expensive product, you could use the MIN function:
MIN(Price)
Count - Counts the number of rows in a column Your notes
To find the number of products in the database, you could use the COUNT function:
COUNT(ProductID)

Remember that the actual syntax and function names might differ slightly depending on the specific
database system being used.

Page 17 of 25

© 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to savemyexams.com for more awesome resources

Sort Data in Databases


Your notes
Sorting Data in Databases
Sorting is a crucial function in databases. It helps organise and present data in a meaningful way.
Using a Single Criterion to Sort Data
You can sort data based on a single criterion - such as by name, date, or numerical value
For example, you might sort a list of students in ascending order by their last names
To sort the customer's tables by LastName in either ascending or descending order:
1. Open the table in Datasheet View
2. Click on the column header for the field to be sorted. For example, a table of customers to be
sorted by LastName, click on the LastName column header
3. Click on the "Sort Ascending" or "Sort Descending" button in the toolbar at the top of the screen

Page 18 of 25

© 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to savemyexams.com for more awesome resources

Using Multiple Criteria to Sort Data


You can also sort data based on multiple criteria Your notes
For instance, you might want to sort a list of products first by category (ascending), and within
each category, by price (descending)
To sort the customer's table first by City , and then by LastName within each city:
1. Open the table in Datasheet View
2. Click on the column header for the first field to be sorted. For example, sorting by City and
then by LastName within each city, first, click on the City column header
3. Click on the "Sort Ascending" or "Sort Descending" button in the toolbar
4. Next, hold down the Shift key and click on the column header for the second field to be
sorted by (LastName in this example)
5. While still holding down the Shift key, click on the "Sort Ascending" or "Sort Descending"
button again
Ascending and Descending Order
Ascending Order - Data is sorted from smallest to largest (e.g., from A to Z, or from 1 to 100)
Descending Order - Data is sorted from largest to smallest (e.g., from Z to A, or from 100 to 1)

Exam Tip
Remember, when sorting by multiple criteria, the data is first sorted by the first criterion.
Within each group of the first criterion, it is sorted by the second criterion, and so on

Page 19 of 25

© 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to savemyexams.com for more awesome resources

Search & Select Data in Databases


Your notes
Search & Select Data in Databases
Searching and selecting data in databases is typically done using queries. These queries can be
based on a single criterion or multiple criteria.
Using a Single Criterion to Select Subsets of Data
You can use a single criterion to select specific data. For example, you might want to select all
customers from a specific city
E.g. to return all customers from London:
1. Open the Query Design View
2. Add the table you want to query
3. Drag the field you want to query to the QBE grid. For instance, if you're looking for customers
from a specific city, drag the City field
4. In the Criteria row under this field, type the value you're looking for (e.g., 'London')

Using Multiple Criteria to Select Subsets of Data


You can also use multiple criteria to select data. For instance, you might want to select all
customers from a specific city who have also purchased in the last month
E.g. to return all customers from London who purchased in the last 30 days:
1. Follow the steps above to start a new query and add the City field with 'London' as the criteria

Page 20 of 25

© 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to savemyexams.com for more awesome resources

2. Drag another field you want to query to the QBE grid. For example, if you're looking for customers
who purchased in the last month, drag the LastPurchaseDate field
3. In the Criteria row under this field, type Date()-30 Your notes
Using Operators to Perform Searches
AND - Returns true if both conditions are met
OR - Returns true if at least one condition is met
NOT - Returns true if the condition is not met
LIKE - Returns true if the value matches a pattern (used with wildcards)
>, <, =, >=, <=, <> - These are comparison operators. They return true if the comparison between
the values is correct
Using Wildcards to Perform Searches
Wildcards are used with the LIKE operator to search for patterns. The most common wildcard
characters are:
% - Represents z ero, one, or multiple characters
_ - Represents a single character
E.g. to return all customers whose names start with 'J':
1. Start a new query and drag the field you want to query to the QBE grid. For example, if you're
looking for customers whose names start with 'J', drag the Name field
2. In the Criteria row under this field, type J*

Exam Tip
Remember, the exact steps and symbols used for wildcards may vary depending on the
specific DBMS and its version. In Microsoft Access, the asterisk (*) is used as the wildcard
character to represent multiple characters, while the question mark (?) represents a single
character
When referring to field names from the exam question, make sure you copy it exactly the way
it appears in the question
Make sure you give the information asked for in the question and not a different field

Page 21 of 25

© 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to savemyexams.com for more awesome resources

Worked example
Your notes
A student is setting up a database of information about volcanoes for a Geography project. The
following is part of the database.

Name_of_volcano Country Height State Last_eruption Volcano_type

Use Japan 731 Active 2001 Stratovolcano


Tor Zawar Pakistan 2237 Dormant 2010 Fissure
Datong China 1882 Extinct 450 Cinder Cone
Changbaishan China 2744 Active 1903 Stratovolcano
Stromboli Italy 926 Active 2016 Stratovolcano
Pyroclastic
Tengchong China 2865 Dormant 1609
cone
Wudalianchi China 597 Dormant 1721 Multi-coned

Operators such as AND, OR, NOT, LIKE, >, >=, <, <=, =, <> can be used to search the volcano
database. The search criteria for all the dormant volcanoes with a height of less than 1000 metres
would look like this:
State = “Dormant” AND Height < 1000
Use only the given operators and data to:
a. write down the search criteria that will produce a list of all the volcanoes that are not extinct in
China that also last erupted before the year 1900.
[6]
State = NOT ‘Extinct’ AND Country = ‘China’ AND Last_eruption < 1900
State = – 1 mark or State <> [1]
NOT ‘Extinct’ – 1 mark or <> ‘Extinct’ [1]
AND Country [1]
= ‘China’ [1]
AND Last_eruption [1]
< 1900 [1]
b. write down the names of the volcanoes that match the requirements of part (a).
[2]

Page 22 of 25

© 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to savemyexams.com for more awesome resources

Tengchong [1]
Wudalianchi [1]
Your notes
c. The data is sorted into ascending order of height. Write down the name of the volcano which
would now be in the first record.
[1]
Wudalianchi [1]

Page 23 of 25

© 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to savemyexams.com for more awesome resources

Present Data
Your notes
Present Data
Data presentation in databases is often done through reports. These reports can be formatted and
customised to display data in a user-friendly manner.
Producing Reports to Display Data
Reports should display all the required data and labels in full. For example, if you're creating a
sales report, it should include all relevant fields, like product name, quantity sold, and total sales
Using Appropriate Headers and Footers
Report Header: This appears at the beginning of the report. This is typically where you would put
the report title and other introductory information
Report Footer: This appears at the end of the report. This is where you might put summary or
conclusion information
Page Header: Appears at the top of each page. This might contain the page number and the date
Page Footer: Appears at the bottom of each page. This might also contain the page number and
the date
Setting Report Titles
The report title should be set in the report header. It should be clear, concise, and accurately
reflect the contents of the report
Producing Different Output Layouts
You can control the display of data and labels in your report. For example, you might choose a
tabular format, where data is arranged in rows and columns, or a columnar format, where each
data field is listed vertically

Page 24 of 25

© 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to savemyexams.com for more awesome resources

Your notes

Aligning Data and Labels


Data and labels should be aligned appropriately. For example, numeric data is often right-aligned,
and decimal points should be aligned for easy comparison
Controlling the Display Format of Numeric Data
You can control the number of decimal places displayed, the use of a currency symbol, and the
display of percentages. For example, a total sales field might be displayed with two decimal
places and a currency symbol

Page 25 of 25

© 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers

You might also like