Professional Documents
Culture Documents
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
Page 2 of 25
© 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to savemyexams.com for more awesome resources
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
This data type allows letters, special characters like spaces and
Text/Alphanumeric NG321AE
punctuation and numbers to be entered into a field
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
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
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:
Complete the following table by entering the most appropriate data type for each field. For any
numeric field, specify the type of number.
Breed
Date_of_birth
Weight_of_cow
Average_milk_yield
Passport_number
[5]
Page 8 of 25
© 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to savemyexams.com for more awesome resources
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
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
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
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
Page 18 of 25
© 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers
Head to savemyexams.com for more awesome resources
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
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.
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
Page 25 of 25
© 2015-2023 Save My Exams, Ltd. · Revision Notes, Topic Questions, Past Papers