0% found this document useful (0 votes)
109 views

1.8 Database and Data Modelling

Uploaded by

Maaz Bin Ali
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
109 views

1.8 Database and Data Modelling

Uploaded by

Maaz Bin Ali
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 137

ASLEVELS9618

DATABASE AND
COMPUTER SCI ENCE DATA MODELLING
Compiled: By Engr. Shahzadah Ashraf Bande’Shah
TOPIC 1.1
Notes + Topical Past
Papers + Marking Scheme

STUDENTS NAME:

shahzadah.ashraf 03332076121
SCHOOL NAME: @gmail.com

Follow On Facebook :
DATE ISSUED: https://www.facebook.com/shahzad
ah.ashraf

For More Resources:


https://sites.google.com/site/Alevelco
mputers/home
CONTACT NUMBER:

A Levels With
Sir Bande'Shah
Page 1 of 136
Cambridge International AS & A Level Computer Science 9618 syllabus for 2021, 2022 and 2023.  Subject content

8 Databases

8.1 Database Concepts

Candidates should be able to: Notes and guidance


Show understanding of the limitations of using a file-
based approach for the storage and retrieval of data
Describe the features of a relational database that
address the limitations of a file-based approach
Show understanding of and use the terminology Including entity, table, record, field, tuple, attribute,
associated with a relational database model primary key, candidate key, secondary key, foreign
key, relationship (one-to-many, one-to-one, many-to-
many), referential integrity, indexing
Use an entity-relationship (E-R) diagram to document
a database design
Show understanding of the normalisation process First Normal Form(1NF), Second Normal Form (2NF)
and Third Normal Form (3NF)
Explain why a given set of database tables are, or are
not, in 3NF
Produce a normalised database design for a description
of a database, a given set of data, or a given set of tables

8.2 Database Management System (DBMS)

Candidates should be able to: Notes and guidance


Show understanding of the features provided by a Including:
Database Management System (DBMS) that address
• data management, including maintaining a data
the issues of a file based approach
dictionary
• data modelling
• logical schema
• data integrity
• data security, including backup procedures and
the use of access rights to individuals / groups of
users
Show understanding of how software tools found Including the use and purpose of:
within a DBMS are used in practice
• developer interface
• query processor

Page 2 of 136
Cambridge International AS & A Level Computer Science 9618 syllabus for 2021, 2022 and 2023. Subject content

8.3 Data Definition Language (DDL) and Data Manipulation Language (DML)

Candidates should be able to: Notes and guidance

Show understanding that DBMS carries out all


creation / modification of the database structure using
its Data Definition Language (DDL)
Show understanding that the DBMS carries out all
queries and maintenance of data using its DML
Show understanding that the industry standard for Understand a given SQL script
both DDL and DML is Structured Query Language
(SQL)
Understand given SQL (DDL) commands and be able Create a database (CREATE DATABASE)
to write simple SQL (DDL) commands using a sub-set Create a table definition (CREATE TABLE), including
of commands the creation of attributes with appropriate data types:
• CHARACTER
• VARCHAR(n)
• BOOLEAN
• INTEGER
• REAL
• DATE
• TIME
change a table definition (ALTER TABLE)
add a primary key to a table (PRIMARY KEY (field))
add a foreign key to a table (FOREIGN KEY (field)
REFERENCES Table (Field))
Write an SQL script to query or modify data (DML) Queries including SELECT... FROM, WHERE, ORDER
which are stored in (at most two) database tables BY, GROUP BY, INNER JOIN, SUM, COUNT, AVG

Data maintenance including. INSERT INTO, DELETE


FROM, UPDATE

Page 3 of 136
Page 4 of 136
8.1 Database Management Systems (DBMS)

What Are Databases?

A database is a stored collection of information arranged in a logical, structured manner. Databases have
been a staple of business computing from the very beginning of the digital era.

Flat File

Originally, databases were flat. This means that the information was stored in one long text file, called
a tab delimited file. Each entry in the tab delimited file is separated by a special character, such as a
vertical bar (|). Each entry contains multiple pieces of information (fields) about a particular object or
person grouped together as a record. For example:

Lname, FName, Age, Salary|Smith, John, 35, $280|Doe, Jane, 28, $325|Brown, Scott, 41,
$265|Howard, Shemp, 48, $359|Taylor, Tom, 22, $250

Flat File Database

When there is only a single table in the database, this is called a 'flat file database'.

A flat file database looks something like this: -

ID Title First name Surname Address City Postcode Telephone


1 Mr Tom Smith 42 Mill Street London WE13GW 010344044
2 Mrs Sandra Jones 10 Low Lane Hull HU237HJ 022344033
2 Mr John Jones 10 Low Lane Hull HU237HJ 022344033

A flat file database is an excellent way of storing a relatively small amount of records (few thousand
perhaps).

For example a spreadsheet application such as Excel can be used as a flat file database. Each row in a
worksheet can be a record and each column, a field. The worksheet is effectively a table.

Features Of Flat File Database:

Placing data in a flat file database has the following advantages


 All records are stored in one place
 Easy to set up using a number of standard office applications
 Easy to understand
 Simple sorting of records can be carried out
 Record can be viewed or extracted on the basis of simple criteria

Everyday things like business contacts, customer lists and so on can be stored and used in a flat file
database.

But they do have some serious disadvantages when it comes to more than a few thousand records.

Page 5 of 136
Disadvantages

1. Potential Duplication
As more and more records are added to the database it becomes difficult to avoid duplicate records. This is
because there is no mechanism built in to the system to prevent duplication. Later you will see how
'primary keys' are used to prevent this.

2. Non-Unique Records

Notice that Mr. & Mrs. Jones have identical ID's. This is because the person producing this database
decided they may want to sort on identical telephone numbers and so has applied identical ID to the two
records. This is fine for that purpose, but suppose you only wanted to extract Mrs. Jones' record. Now it is
much more difficult.

3. Harder To Update

Suppose that this flat file database also stored their work place details - this will result in multiple records
for each person. Again, this is fine - but suppose Sandra Jones now wanted to be known as 'Sandra
Thompson' after re-marrying? This will have to be done over potentially many records and so flat file
updates are more error-prone than other methods

4. Inherently Inefficient
Consider a situation where the database now needs to hold an extra field to hold their email address. If
there are tens of thousands of records, there may be many people having no email address, but each
record in a flat file database has to have the same fields, whether they are used or not. Other methods
avoid this wasted storage.

5. Harder To Change Data Format


Suppose the telephone numbers now have to have a dash between the area code and the rest of the
number, like this 0223-44033. Adding that extra dash over tens of thousands of records would be a
significant task in a flat file database.

6. Poor At Complex Queries


If we wanted to find all records with a specific telephone number, this is a simple single-field criteria that a
flat file can easily deal with. But now suppose we wanted all people living in Hull who share the same
surname and similar postcode? - The criteria can quickly become too complex for a flat file to manage.

7. Poor At Limiting Access


Suppose this flat file database held a confidential field in each record that only certain staff are allowed to
see - perhaps salaries. This is difficult to achieve in a flat file database - once a person has entered a valid
password to gain access, that person is able to see everything.

Because of these limitations other types of database have been developed.

Page 6 of 136
Relational Database

To overcome the limitations of a simple flat file database that has only a single table, another type of
database has been developed called a 'relational database'.

A relational database holds its data over a number of tables instead of one. Records within the tables are
linked (related) to records held in other tables.

The picture below shows two tables. The main one is called 'customers'. This contains almost the same
fields as we have seen in the flat file database. But there is one key difference - the city is now held in a
separate table called 'city'. The line between them shows there is a link (relationship) between a record in
the city table and records in the main table.

The line between the fields has a '1' on one side and the infinity sign on the other. In Access this indicates a
'one-to-many' relationship. This is described in more detail on the Entity Relationship Diagram.

A small relational database may only contain two tables whilst a large corporate database could contain
hundreds of tables.

Page 7 of 136
Advantages Of A Relational Database

Splitting data into a number of related tables brings many advantages over a flat file database. These
include:

1. Data Is Only Stored Once

In the previous example, the city data was gathered into one table so now there is only one record per
city. The advantages of this are

 No multiple record changes needed


 More efficient storage
 Simple to delete or modify details.
 All records in other tables having a link to that entry will show the change.

2. Complex Queries Can Be Carried Out

A language called SQL has been developed to allow programmers to 'Insert', 'Update', 'Delete', 'Create',
'Drop' table records. These actions are further refined by a 'Where' clause. For example

SELECT * FROM Customer WHERE ID = 2

This SQL statement will extract record number 2 from the Customer table. Far more complicated queries
can be written that can extract data from many tables at once.

3. Better Security

By splitting data into tables, certain tables can be made confidential. When a person logs on with their
username and password, the system can then limit access only to those tables whose records they are
authorized to view. For example, a receptionist would be able to view employee location and contact details
but not their salary. A salesman may see his team's sales performance but not competing teams.

4. Cater For Future Requirements

By having data held in separate tables, it is simple to add records that are not yet needed but may be in the
future. For example, the city table could be expanded to include every city and town in the country, even
though no other records are using them all as yet. A flat file database cannot do this.

Summary - advantages of a relational database over flat file

 Avoids data duplication


 Avoids inconsistent records
 Easier to change data
 Easier to change data format
 Data can be added and removed easily
 Easier to maintain security.

Page 8 of 136
DBMS (Data Base Management System)

It’s a software that handles the storage, retrieval, and updating of data in a computer system.

A DBMS provides an environment that is both convenient and efficient to use when there is a large volume
of data and many transactions to be processed. Different categories of DBMS can be used, ranging from
small systems that run on personal computers to huge systems that run on mainframes.

Page 9 of 136
Benefits of DBMS:

A DBMS is responsible for processing data and converting it into information. For this purpose, the database
has to be manipulated, which includes querying the database to retrieve specific data, updating the
database, and finally, generating reports.

These reports are the source of information, which is, processed data. A DBMS is also responsible for data
security and integrity.
The benefits of a typical DBMS are as follows:

Data Storage

The programs required for physically storing data, handled by a DBMS, is done by creating complex data
structures, and the process is called data storage management.

Data Definition

A DBMS provides functions to define the structure of the data in the application. These include defining and
modifying the record structure, the type and size of fields, and the various constraints/conditions to be
satisfied by the data in each field.

Data Manipulation

Once the data structure is defined, data needs to be inserted, modified, or deleted. The functions, which
perform these operations, are also part of a DBMS. These functions can handle planned and unplanned data
manipulation needs. Planned queries are those, which form part of the application. Unplanned queries are
ad-hoc queries, which are performed on a need basis.

Data Security And Integrity

Data security is of utmost importance when there are multiple users accessing the database. It is required
for keeping a check over data access by users. The security rules specify, which user has access to the
database, what data elements the user has access to, and the data operations that the user can perform.
Data in the database should contain as few errors as possible. For example, the employee number for adding
a new employee should not be left blank. Telephone number should contain only numbers. Such checks are
taken care of by a DBMS.
Thus, the DBMS contains functions, which handle the security and integrity of data in the application. These
can be easily invoked by the application and hence, the application programmer need not code these
functions in the programs.

Data Recovery And Concurrency

Recovery of data after a system failure and concurrent access of records by multiple users are also handled
by a DBMS.

Performance

Optimizing the performance of the queries is one of the important functions of a DBMS. Hence, the DBMS
has a set of programs forming the Query Optimizer, which evaluates the different implementations of a
query and chooses the best among them.

Page 10 of 136
Multi-User Access Control

At any point of time, more than one user can access the same data. A DBMS takes care of the sharing of data
among multiple users, and maintains data integrity.

Database Access Languages And Application Programming Interfaces (APIS)

The query language of a DBMS implements data access. SQL is the most commonly used query language. A
query language is a non-procedural language, where the user needs to request what is required and need
not specify how it is to be done. Some procedural languages such as C, Visual Basic, Pascal, and others
provide data access to programmers through these APIs and other tools.

Data Modelling

Conceptual, logical and physical schema

This shows that a data model can be an external model (or view), a conceptual model, or a physical model.
This is not the only way to look at data models, but it is a useful way, particularly when comparing models.

Conceptual Schema

Describes the semantics of a domain (the scope of the model). For example, it may be a model of the
interest area of an organization or of an industry. This consists of entity classes, representing kinds of
things of significance in the domain, and relationships assertions about associations between pairs of
entity classes. A conceptual schema specifies the kinds of facts or propositions that can be expressed using
the model. In that sense, it defines the allowed expressions in an artificial "language" with a scope that is
limited by the scope of the model. Simply described, a conceptual schema is the first step in organizing the
data requirements.

Page 11 of 136
Logical Schema

Describes the structure of some domain of information. This consists of descriptions of (for example)
tables, columns, object-oriented classes, and XML tags. The logical schema and conceptual schema are
sometimes implemented as one and the same.

Physical Schema

Describes the physical means used to store data. This is concerned with partitions, CPUs, table spaces, and
the like.

According to ANSI, this approach allows the three perspectives to be relatively independent of each other.
Storage technology can change without affecting either the logical or the conceptual schema. The
table/column structure can change without (necessarily) affecting the conceptual schema. In each case, of
course, the structures must remain consistent across all schemas of the same data model.

Database Schema

Database schema is the skeleton of database. It is designed when database doesn't exist at all and very
hard to do any changes once the database is operational. Database schema does not contain any data or
information.

A database schema defines its entities and the relationship among them. Database schema is a descriptive
detail of the database, which can be depicted by means of schema diagrams. All these activities are done
by database designer to help programmers in order to give some ease of understanding all aspect of
database.

Database Schema Can Be Divided Broadly In Two Categories:

Physical Database Schema: This schema pertains to the actual storage of data and its form of storage like
files, indices etc. It defines the how data will be stored in secondary storage etc.

Logical Database Schema: This defines all logical constraints that need to be applied on data stored. It
defines tables, views and integrity constraints etc.

Developer Environment And Query Processor

Every database software provides the interface to design schemas and manipulate data through the query
processors.

Page 12 of 136
1.8.2 Relational Database Modelling

RDBMS (Relational Database Management System)

A relational database consists of at least two tables along with a definition of the relationships between
the two tables.

At this level of complexity, it is straightforward to keep the data consistent. The term used is 'data
integrity'. For example if a record in one table is deleted, then a related record in the other table may have
to be deleted as well because they share a relationship. If the deletion is not done properly then you end
up with 'orphan' records that have no relevance and are just taking up storage.

Another problem might be trying to insert data into a field of the wrong data type, for example inserting a
string into a Boolean field will cause an error.
What is needed is a piece of software that can keep track of all the rules implicit in the database and to
maintain data integrity.

This software is called a 'Relational Database Management System' or RDBMS.

The prime purpose of a relational database management system is to maintain data integrity. This means
all the rules and relationships between data are consistent at all times.
But a good DBMS will have other features as well.
These include:

 A command language that allows you to create, delete and alter the database (data description
language or DDL)
 A way of documenting all the internal structures that make up the database (data dictionary)
 A language to support the manipulation and processing of the data (data manipulation language)
 Support the ability to view the database from different viewpoints according to the requirements of
the user
 Provide some level of security and access control to the data

The simplest RDBMS may be designed with a single user in mind e.g. the database is 'locked' until that
person has finished with it. Such a RDBMS will only cost a few hundred pounds at most and will have only a
basic capability.

On the other hand an enterprise level DBMS can support a huge number of simultaneous users with
thousands of internal tables and complex 'roll back' capabilities should things go wrong.

Obviously this kind of system will cost thousands along with a need to have professional database
administrators looking after it and database specialists to create complex queries for management and
staff.

Page 13 of 136
Data Dictionary:

A 'data dictionary' describes the structure and attributes of data 'items' to be used within a software
application (usually a database).

A data dictionary includes the names and descriptions of the tables and the fields contained in each table.
It also documents information about the data type, field length and other things such as validation.
The main purpose of the data dictionary is to provide metadata, or information about data. Technically, it
is a database about a database.
There is no one set standard in terms of layout or the level of detail to which a data dictionary should be
written.
Software development teams need a comprehensive data dictionary to refer to during the development
and maintenance of a new database. This is so that they are all working using the same data formats when
reading or writing data.

Typical Data Dictionary


When putting together a data dictionary for a database project, the analyst considers what kind of
information needs to be documented.

The table below shows some of them:

Table name The unique name of every table in the database

Field names List of every field name in the database

The data type allocated for a particular field, for example,


Field data type
text, date, Boolean

The number of elements that have been allocated for storing


Field length
data in that field e.g. Integer(11) or Varchar(50)

i.e. what will automatically appear in the field of any new


Default value of fields
record

Presence checks, lookup, range checks, picture check which


Field validation
are applied to a field

Page 14 of 136
Keys The primary and foreign keys for each table

Relationships e.g. one-to-many

Indexes Any field that has been indexed to improve search speed

Access rights or permissions for the


i.e. who can change / edit / modify / read only
database

Data Dictionary Example


The table below is an example of a typical data dictionary entry. The IT staff uses this to develop and
maintain the database.

Field Name Data Type Other information

CustomerID Autonumber Primary key field

Lookup: Mr, Mrs, Miss, Ms


Title Text
Field size 4

Field size 15
Surname Text
Indexed

FirstName Text Field size 15

Format: Medium Date


DateOfBirth Date/Time
Range check: >=01/01/1930

Field size: 12
HomeTelephone Text
Presence check

Page 15 of 136
Terminology Associated With A Relational Database Model

There are a lot of new terms to learn when you begin to cover the database section at AS level. Some of
these terms that you must understand and be able to use are entities and attributes. You must also
understand how to draw and interpret an entity relationship (E-R) diagram.

Entities

An Entity is a person, place, thing or concept about which data can be collected. Examples include
EMPLOYEE, HOUSE, and CAR

A database contains one or more related tables.


Each table holds all of the information about an object, person or thing.

Some examples of database tables might be:

- a customer table

- an appointments table

- an exam sessions table

- a teachers' names table

- a concert venue table

Page 16 of 136
Attributes

An attribute describes the facts, details or characteristics of an entity


Remember that an entity is a person, place, thing or concept about which data can be collected.
Each entity is made up of a number of 'attributes' which represent that entity.

Example

Database Relationships

Entity Relationship Diagrams

These relationships can be shown in the form of


a diagram.
This diagram is known as an 'entity relationship
diagram', E-R diagram or ERD
As part of your exam, you will probably have to
either draw or interpret an E-R diagram. Before
you can do this, you need to be able to interpret
the relationships between the entities.
These relationships take the form of:

- One-to-one
- One-to-many
- Many-to-many
Page 17 of 136
Diagram Name Description

Many to An Author can write several Books, and a


Many Book can be written by several Authors

A Biological Mother can have many


One to
children, and a child can have only one
Many
Biological Mother

One to A Country has only one Capital City, and


One a Capital City is in only one Country

Changing A Many-To-Many Into A One-To-Many Relationship

A many-to-many relationship is not a good idea when designing database relationships.


To overcome this, an extra entity is usually added to the database design which then allows the
relationship to become a many-to-one or a one-to-many relationship.
Remember our example on the previous page

A third entity can be added called 'rentals'.


Thus the relationship becomes:
Customers can have many different rentals
A rental belongs to one customer
AND
A video can be rented many times
Many rentals can contain that video

Page 18 of 136
Designing Relationships

When designing or solving relationships for an E-R diagram, it is helpful to remember the following
information:

The 'Many' side is usually the foreign key


The 'One' side is usually the primary key

Before you design or set up a database, you should work out:

- The entities
- The attributes
- The entity relationships

This process is called 'data modelling'

Database Keys

We have discussed flat-file and relational databases.


A fundamental feature of a database is the ability to point to any given record. After all, what is the use of
a database if you can't get to the right records?
With this in mind, the concept of a 'key' was developed.

- Primary key
- Secondary key
- Foreign key
- Compound primary Key

Primary Key

Primary keys are an essential part of relational database design.


The 'primary key' of a table uniquely identifies each record.

Many primary keys are single field values but more complex situations may use several attributes to define
a primary key. Then it is called a 'compound primary key'.

*Additional point

Primary keys do not have to be numbers; they can be anything that makes each record unique.
For example, a username-password table might have a fixed length 'hash' value as its primary key, like this:

ID username password
1dab223bffh joe ninety

Page 19 of 136
Foreign Key

A foreign key points to a record in another table whose primary key is the same value.
What is happening is that a copy of the primary key value in the City table is being stored in the customers
table. For example, a typical record entry looks like this:

Mr. & Mrs. Jones live in the city of Hull and the foreign key in each record contains '2'. This then points to
'Hull' in the city table whose primary key is also '2'.

Note that it’s quite common to have more than one record having the same foreign key.

This simply reflects the fact that a one-to-many relationship exists between the two tables.

Secondary Key

Primary key is the main way that records within a table are defined and sorted. But it is also useful to be
able to select certain category of records without having to use the primary key.

For example, with the customer records shown above perhaps a useful way to view records would be by
title. In which case a 'secondary key' is set up within the database. This secondary key indexes the records
according to title.

Page 20 of 136
The good thing about secondary keys is that the secondary index allows often-queried category of records
to be extracted far quicker. But the downside is that the indexes could make the database significantly
larger. So the database analyst has to carefully weigh up the benefit of adding secondary keys to the
database.

Secondary keys do not have to be single fields, they can be a combination of fields. In the example below a
secondary key is indexing records based on title and surname. so it would be a really quick query to extract
all people called 'Mr. Jones'

Normalization
Desired characteristics of a database include it being efficient in terms of storage and easy to maintain.
The first point, of storage, means redundant data should be avoided and the second point, of maintenance,
means that a good design will logically separate data into tables.

Normalization is a design method that can be used to achieve this.


What is normalization?

“a technique for designing relational database tables to minimize duplication of information and, in so
doing, to safeguard the database against certain types of logical or structural problems” (wikipedia.com)

Normalization provides rules that help:

- Organize the data efficiently.


- Eliminate redundant data.
- Ensure that only related data are stored in a table.

First Normal Form - 1NF

For a database to be in first normal form (1NF), the following rules have to be met for each table in
the database

- There are no columns with repeated or similar data


- Each data item cannot be broken down any further.
- Each row is unique i.e. it has a primary key
- Each field has a unique name

'Atomic' is the word used to describe a data item that cannot be broken down any further.

Page 21 of 136
Which of these tables are NOT in first normal form?

1.

Title Firstname Surname Full name Address City Postcode

Mr Tom Smith Tom Smith 42 Mill Street London WE13GW

2.

ID IP Address username last accessed Activity Result active

1003 198.168.1.5 Smith 20081021:14.10 Save file success y

3.

ItemID Product Description Size Colour Colour Colour

234 Shoe High Heel 6 red blue brown

4.

StudentID Firstname Surname SchoolID* ClassID*

354 Tom Smith 6 5F

Comments:

Table 1. This is not in 1NF. There is no primary key defined and so this record cannot be guaranteed to be
unique. Also Full name is redundant - data is not atomic - as it is simply a combination of Firstname and
Surname.

Table 2. This is in at least 1NF. It has a primary key identified by the underline. The data is atomic. Each
field has a unique name. There are no repeat data.

Table 3. This is not in 1NF. It has a primary key, so it passes that test, data is atomic - tick in the box, but
the colour the shoe can come in is being repeated - and furthermore the fields have the same name - so
not in 1NF

Table 4. This is in 1NF as it meets all the rules for the first normal form.

Question to ask yourself to spot 1NF

Does it have a primary key?


Are each field name unique?
Is the data atomic?
Are there repeating / redundant fields.

Page 22 of 136
1NF Examples 2

Suppose a designer has been asked to compile a database for a fan club web site. Fans visit the web site to
find like-minded friends.
The entities to be stored are
This indicates that each band has many fans. Each person is a fan of only one group.

BAND FAN
The attributes of a fan are:
The attributes of band are:
FanID
BandID
firstname
band name
surname
musictype
email address(es)
The database needs to be in first normal form.

First Attempt

This is the first time this person has designed a database and is not really sure of how to go about it. He
designs the FAN table and loads it with the following records

FanID Firstname Surname BandID* email

1 Tom Smith 23 tm@fan.org

2 Mary Holden 56 mh@fan.org , mary@myhome.org

He has correctly set up a primary key. He also used a foreign key to refer to the band. But this is not in 1NF
because Mary has two email addresses loaded into the email field. The data is not atomic. Loading data in
this way is also going to make it very difficult to extract email addresses. Also the data length of the email
field now has to be long enough to handle many email addresses, this is very inefficient and would be a
problem if exceeded.

Second Attempt

He soon realizes this is not a good idea. So then he decides to create two email fields

FanID Firstname Surname BandID* email email2

1 Tom Smith 23 tm@fan.org

2 Mary Holden 56 mh@fan.org mary@myhome.org

This is also a poor approach - note that email2 is not being used in Tom's record and so is causing wasted
storage, so not 1NF which seeks to avoid wasted / redundant data.
Another problem is what if a fan has many more emails? Adding more and more email fields will make the
wasted storage even worse.
Another problem is that the query to extract email addresses is far more complex than it needs to be as it
has to examine each email field.

Page 23 of 136
Solution

After trying out various ideas, he comes up with a good solution - create another entity called 'email' and
use a foreign key in that table to link the fan and email tables together. The ER diagram is as follows:

The ER diagram shows that each fan can have many emails, but an email can only belong to one fan.
The FAN and EMAIL table now look like this

FAN

FanID Firstname Surname BandID*


1 Tom Smith 23
2 Mary Holden 56

EMAIL

EID FanID* email


1 1 tm@fan.org
2 2 mh@fan.org
3 2 mary@myhome.org

Mary (FanID = 2) has two entries in the email table. There is no problem adding even more emails for her.
Extracting emails is now simple as there is only one email column. There is no wasted storage.

The tables are now in first normal form (1NF) as they obey the following rules

- Each table has a primary key


- Each field name is unique
- Data is atomic
- No repeating / redundant fields

Page 24 of 136
Second Normal Form 2NF

Most tables tend to have a single-attribute (i.e. simple) primary key. Like this

CUSTOMER

ID Firstname Surname Telephone email


2 Tom Smith 22323 ts@aol.com

But sometimes a table has a primary key made up of more than one attribute i.e. it has a compound
primary key.

CONCERT

Venue Artist Attendance Profit Style


Wembley Girls Aloud 53000 12334 Girl band
NEC Leona Lewis 45000 66433 Female soloist

The table above is using both the venue and artist as the compound primary key.
It is in this situation that the extra rule for second normal form comes in handy. The rule states

Non-key attributes must depend on every part of the primary key


The table must already be in first normal form

So inherently, any table that is already in 1NF and has a simple primary key is automatically in second
normal form as well.

Consider the Concert example above - this is NOT in second normal form. Notice the attribute called Style.
This is describing the style of artist - it has nothing to do with where the concert took place! And so its
value does not depend on EVERY part of the primary key, so the rule for second normal form is not being
met.

The reason for this rule is to ensure there is no redundant data being stored.

For example, let's add another Girls Aloud concert to the table

Venue Artist Attendance Profit Style


Wembley Girls Aloud 53000 12334 Girl band
NEC Leona Lewis 45000 66433 Female soloist
NEC Girls Aloud 76090 53789 Girl band

Notice that the 'girl band' value is being repeated and so is causing the database to be bigger than it needs
to be.

Of course there could be more than one attribute related to different parts of the primary key. Consider a
table like this:

Page 25 of 136
CONCERT

Venue Artist Date Attendance Profit City No1Hits Style


Wembley Girls Aloud 1/10/09 53000 12334 London 5 Girl band
NEC Leona Lewis 1/10/09 45000 66433 Birmingham 2 Female soloist
NEC Girls Aloud 7/11/09 76090 53789 Birmingham 5 Girl band

As before the Style attribute only depends on Artist, but now No1Hits also only depends on the Artist. This
table also includes City and this only depends on the Venue.

So to make this database into second normal form, four tables need to be created

CONCERT

VenueID Artist Date Attendance Profit


005 0112 1/10/09 53000 12334
006 0115 1/10/09 45000 66433
006 0112 7/11/09 76090 53789

STYLE
Style ID Style
001 Girl band
002 Solo artist
003 Rap

ARTIST
ArtistID Artist No1Hits StyleID
0112 Girls Aloud 20 001
0115 Leona Lewis 3 002

VENUE
Venue ID Venue City
005 Wembly London
006 NEC Birmingham

Summary
The rules for second normal form are

 Non-key attributes must depend on every part of the primary key


 The table must already be in first normal form Page 26 of 136
Third Normal Form
For a database to be in third normal form, the following rules have to be met

- It is already in 2NF
- There are no non-key attributes that depend on another non-key attribute

What this is trying to do is to spot yet another source of redundant data. If the value of an attribute can be
obtained by simply making use of another attribute in the table, then it does not need to be there. Loading
that attribute into another table and linking to it will make the database smaller.

To clarify, consider the table below

CONCERT

Venue Artist Date Attendance Profit City Country


Wembley Girls Aloud 1/10/08 53000 12334 London UK
NEC Leona Lewis 1/10/08 45000 66433 Birmingham UK
Carnegie Hall Girls Aloud 7/11/08 76090 53789 New York USA

Notice that the country could be obtained by referring to the City - if the concert was in London then you
know it is also in the UK - no need to look at the primary key!

So to make this database into third normal form, split the table as follows

CONCERT

Venue Artist Date Attendance Profit City*


Wembley Girls Aloud 1/10/08 53000 12334 London
NEC Leona Lewis 1/10/08 45000 66433 Birmingham
Carnegie Hall Girls Aloud 7/11/08 76090 53789 New York

CITIES

City Country
London UK
Bimingham UK
New York USA

The new table called CITIES has City as the primary key and country as an attribute. The Concert table has
City as a foreign key. So now you can obtain the country in which any particular concert took place and
there is no redundant data.

Page 27 of 136
3NF Examples

Reminder, 3NF means:

- It is already in 2NF
- There are no non-key attributes that depend on another non-key attribute

Example 1

CUSTOMER

CustomerID Firstname Surname City PostCode


12123 Harry Enfield London SW7 2AP
12443 Leona Lewis London WC2H 7JY
354 Sarah Brightman Coventry CV4 7AL

This is not in strict 3NF as the City could be obtained from the Post code attribute. If you created a table
containing postcodes then city could be derived.

CustomerID Firstname Surname PostCode*


12123 Harry Enfield SW7 2AP
12443 Leona Lewis WC2H 7JY
354 Sarah Brightman CV4 7AL

POSTCODES

PostCode City
SW7 2AP London
WC2H 7JY London
CV4 7AL Coventry

Example 2

VideoID Title Certificate Description


12123 Saw IV 18 Eighteen and over
12443 Igor PG Parental Guidance
354 Bambi U Universal Classification

The Description of what the certificate means could be obtained from the certificate attribute - it does not
need to refer to the primary key VideoID. So split it out and use the primary key / secondary key approach.

Page 28 of 136
Example 3

CLIENT

ClientID CinemaID* CinemaAddress


12123 LON23 1 Leicester Square. London
12443 COV2 34 Bramby St, Coventry
354 MAN4 56 Croydon Rd, Manchester

CINEMAS

CinemaID CinemaAddress
LON23 1 Leicester Square. London
COV2 34 Bramby St, Coventry
MAN4 56 Croydon Rd, Manchester

In this case the database is almost in 3NF - for some reason the Cinema Address is being repeated in the
Client table, even though it can be obtained from the Cinemas table. So simply remove the column from
the client table

Example 4

ORDER

OrderID Quantity Price Cost


12123 2 10.00 20.00
12443 3 20.00 60.00
354 4 30.00 120.00

In this case the cost of any order can be obtained by multiplying quantity by price. This is a 'calculated
field'. The database is larger than it needs to be as a query could work out the cost of any order. So to be in
strict 3NF you would remove the Cost column.

Benefits Of Normalization

1. The database does not have redundant data; it is smaller in size so less money needs to be spent on
storage.

2. Because there is less data to search through, it is much faster to run a query on the data.
3. Because there is no data duplication there is better data integrity and less risk of mistakes.
4. Because there is no data duplication there is less chance of storing two or more different copies of the
data.

5. Once change can be made which can instantly be cascaded across any related records.

Page 29 of 136
Problems With Normalization

1. You need to be careful with trying to make data atomic. Just because you can split some types
of data further, it isn't always necessarily the correct thing to do. For example, telephone
number might contain the code followed by the number 01234 567890. It wouldn't be sensible
to separate out these two items.

2. You can end up with more tables than an unnormalised database

3. The more tables and the more complex the database, the slower queries can be to run

4. It is necessary to assign more relationships to interact with larger numbers of tables

5. With more tables, setting up queries can become more complex

Page 30 of 136
1.8.3 Data Definition Language (DDL) And Data Manipulation Language
(DML)

DML (Data Manipulation Language)

One of the functions of a RDBMS is to provide a means of manipulating data within the database. This
includes operations such as

 Insert
 Delete
 Update
 Process data

This is the role of the data manipulation language (DML) built in to the system.

However, writing commands by hand can be slow and error prone. So to help with this, many systems
allow the user to set up a task by using 'Query by Example'. The users are presented with a graphical view
of the tables and they then use a number of icons such as 'filter' to manipulate the data. With some
systems you can drag fields graphically into appropriate areas on the screen to set up the query.

Behind the scenes, the QBE tool is compiling and running the required DML commands.

It means that users do not need to have a sophisticated understanding of database command languages in
order to use the database.

DDL (Data Description Language)

One of the basic functions of a RDBMS is to provide a method of creating a database from scratch. This is
the role of the data description language (DDL).

The language allows tables to be defined in terms of:

 Field names
 Data type
 Data size / length
 Validation rules
 Default values
 Presence check
 Auto incrementing requirement
 Indexing requirement
 Primary key

As each table is defined and the relationships between them is established, then the overall design
emerges. This is called the 'Schema'.

It should be noted that a single large database may have several groups of people using it for different
purposes. In which case a different schema is needed for each of them.

Page 31 of 136
SQL

Structured Query Language (SQL) is used to perform function on a database. There are four main functions
that you should be familiar with: SELECT, INSERT, UPDATE, and DELETE.

Built in SQL commands are normally written in capital letters, making your statements easier to read.
However, you can get away without them.

To help us understand how these things work we are going to use a test data set. Databases are used in all
areas of the computer industry, but for the moment we are going to use a dataset that keeps track of
crooks in England, noting, names, gender, and date of birth, towns and numbers of scars. Take a look at the
crooks data table below:

ID name gender DoB town numScars


1 Geoff male 12/05/1982 Hull 0
2 Jane female 05/08/1956 York 1
3 Keith male 07/02/1999 Snape 6
4 Oliver male 22/08/1976 Blaxhall 2
5 Kelly female 11/11/1911 East Ham 10
6 Marea female 14/07/1940 Wythenshawe 6

To select all the items from this table we can use:

SELECT * FROM crooks

This would display all the results. But what if we just want to display the names and number of scars of the
female crooks?

SELECT name, numScars FROM crooks


WHERE gender = 'female'

The result of this query would be:

name numScars
Jane 1
Kelly 10
Marea 6

SELECT

The SELECT statement allows you to ask the database a question (Query it), and specify what data it
returns. We might want to ask something like Tell me the name and ages of all the crooks. Of course this
wouldn't work, so we need to put this into a language that a computer can understand: Structured Query
Language or SQL for short:

Page 32 of 136
SELECT name, DoB --what to return
FROM crooks --where are you returning it from

This would return the following:


name DoB
Geoff 12/05/1982
Jane 05/08/1956
Keith 07/02/1999
Oliver 22/08/1976
Kelly 11/11/1911
Marea 14/07/1940

But suppose we wanted to filter these results, for instance: Tell me the ID, name and ages of all the crooks
who are male and come from Snape. We need to use another statement, the WHERE clause, allowing us to
give the query some criteria (or options):

SELECT ID, name, DoB


FROM crooks
WHERE town = 'Snape' AND gender = 'male' --Criteria

This would return the following:


ID name DoB
3 Keith 07/02/1999

Say the police knew that a crime had been committed by a heavily scarred woman (4+ scars), they want a
list of all the scarred women:

SELECT name, town, scars


FROM crooks
WHERE numScars >= 4 AND gender = 'female' --Criteria

This would return:


name town numScars
Kelly East Ham 10
Marea Wythenshawe 6

However, the police want to quickly sort through and see who is the most heavily scarred. We are going to
use an ORDER command:

SELECT name, town


FROM crooks
WHERE numScars >= 4 AND gender = 'female' --Criteria
ORDER BY numScars DESC --sorts the numScars values in big to small order

ORDER BY numScars sorts your returned data into DESCending (big to small) or ASCending (small to big)
order

Page 33 of 136
INNER JOIN

We spoke earlier about how databases are great because they allow you to link tables together and
perform complex searches on linked data. So far we have only looked at searching one table.

When you use a social network such as Facebook you can often see a list of all your friends in the side bar
as well as details from your record such as your name and place of work. How did they find this data? They
would have searched for all the relationships that involve your ID, returning the names of people involved
AND returned values such as job title from your personal record.

This looks like using two queries: --return relationship information—return personal record information It
would be possible to do this, but it's far easier to use one query for both things.

Take a look at this example. The police want to know the name and town of a criminal (ID = 45) along with
all the descriptions of crimes they have performed:

SELECT name, town, description --select things to return (from different tables)
FROM crooks, crime --name tables that data comes from
WHERE crook.Id = crime.crimId --specify the link dot.notation means table.field. The Ids are the same
AND crook.Id = 45 --specify which crook you are looking at
ORDER BY date ASC --order the results by the oldest first

Operators Used In The WHERE Clauses

Operator Meaning of the operator Example


= Checks if they're equivalent Id1 = 123

Checks if a field is greater than or less Id1 > 123


> and <
than Id1 < 123

<> Checks if it's not equal to Id1 <> 123

Similar to "> and <", but also checks for Id1 >= 123
>= and <=
equality Id1 <= 123

Will be accepted if either the left, right


OR Id1 = 123 OR Id2 <> 444
or both are true

Only accepted if both the left part and


AND Id1 = 123 AND Id2 <> 444
the right part are true

Inverts the boolean value of the


NOT NOT Id1 = 123
statement

Checks if it's a null value contained


IS NULL Id1 IS NULL
within the variable

... BETWEEN ...


Checks if something is within a range Id1 BETWEEN 2.8 AND 3.14159265
AND ...

Page 34 of 136
DML (Data Manipulation Language)

 Insert
 Delete
 Update
 Process data

UPDATE

Database aren't always perfect and there may be times that we want to change the data inside our
database. For example in Facebook if someone is annoying you and you limit their access to your profile,
you'd update the access field from 'normal' to 'restricted'. Or if one of our crooks gets an additional scar
you'd have to update the numScars field.
Let's take a look at that example, where our crook Peter gains a scar on his right cheek. This was his initial
state:
name: Peter
numScars: 7
UPDATE crooks
SET numScars = 8

But we have a problem here, this statement updates all records to numScars = 8. This means that every
crook will now have 8 scars!

ID name gender DoB town numScars


1 Geoff male 12/05/1982 Hull 8
2 Jane female 05/08/1956 York 8

3 Keith male 07/02/1999 Snape 8

4 Oliver male 22/08/1976 Blaxhall 8


5 Kelly female 11/11/1911 East Ham 8
6 Marea female 14/07/1940 Wythenshawe 8

We need to specify which crooks we want to update by using a WHERE clause, you saw it earlier in the
SELECT example.

UPDATE crooks
SET numScars = 8
WHERE name = "Peter" --only updates those people who are called Peter

Page 35 of 136
INSERT

We might also want to add new things to our database, for example when we are adding new Criminal
records or a new friendship link on Facebook. To add new records we use the INSERT command with values
of the fields we want to insert:

INSERT INTO crooks


VALUES (1234,'Julie', 'female','12/12/1994','Little Maplestead',67)

Sometimes we might not want to insert all the fields, some of them might not be compulsory:

INSERT INTO crooks (ID, name, town) --specific fields to insert into
VALUES (999, 'Frederick', 'Shotley')

ID name gender DoB town numScars


1 Geoff male 12/05/1982 Hull 0
2 Jane female 05/08/1956 York 1
3 Keith male 07/02/1999 Snape 6
4 Oliver male 22/08/1976 Blaxhall 2
5 Kelly female 11/11/1911 East Ham 10
6 Marea female 14/07/1940 Wythenshawe 6
1234 Julie female 12/12/1994 Little Maplestead 67
999 Frederick Shotley

DELETE

Sometimes you might fall out with friends on Facebook so that you don't even want them to see your
restricted page. You'd want to delete your relationship (it's actually likely that Facebook retains the
connection but flags it as 'deleted', that isn't important here). The police might also find that a crook is in
fact innocent and then want to delete their criminal record. We need a DELETE command to do all of these
things, to permanently delete records from databases. Imagine that we find out that Geoff was framed and
he is completely innocent:

DELETE FROM crooks


WHERE name = 'Geoff'

Page 36 of 136
Data Definition Language (DDL)

- Create tables: CREATE TABLE


- Change the structure of a table: ALTER
- Delete tables: DROP

CREATE

You need to know what they all do (as listed above), though you only need to know how to implement the
CREATE TABLE command. Let's look at how we could have made the crooks table above:

CREATE TABLE crooks


(
ID INTEGER PRIMARY KEY,
NAME VARCHAR(16),
GENDER VARCHAR(6),
DOB DATE,
TOWN VARCHAR(20),
NUMSCARS INTEGER
)

ALTER

An ALTER statement in SQL changes the properties of a table in a relational database without the need to
access the table manually.

ALTER TABLE crooks ADD convictions INTEGER


ALTER TABLE crooks DROP COLUMN convictions

DROP

Dropping a table is like dropping a nuclear bomb. It is irreversible and is frowned upon in modern society.

DROP TABLE crooks

By running this line of code, the table "crooks" will be removed from the database with no chance of it
being recovered unless backups have been previously made.

Page 37 of 136
Setting Primary Keys

Primary keys can be set after table creation via the alter statement.

ALTER TABLE Persons


ADD PRIMARY KEY (id)

Primary keys can also be set during table creation

CREATE TABLE users


(
user_id int NOT NULL,
username varchar(255) NOT NULL,
password varchar(255) NOT NULL,
Address varchar(255),
PRIMARY KEY (user_id)
)

Setting Composite Keys

To set a primary key made up of two columns during table creation you could do something such as this

CREATE TABLE users


(
user_id int NOT NULL,
username varchar(255) NOT NULL,
password varchar(255) NOT NULL,
Address varchar(255),
CONSTRAINT pk_UserId PRIMARY KEY (user_id,username)
)

Where the constraint name would be UserId and the table's primary key would be made up of the user_id
and the username columns.
This could also be done after table creation:

ALTER TABLE users


ADD CONSTRAINT pk_UserID PRIMARY KEY (user_id,username)

Setting Foreign Keys

To set a foreign key or group of foreign keys during table creation, you could do something like this:

CREATE TABLE FoodProduct


(
product_id int NOT NULL,
product_name varchar(255) NOT NULL,
ingredients varchar(1023) NOT NULL,
allergen varchar(511) NOT NULL
)

Where the primary key is "product_id" and all the other attributes are declared within the ( ) structure and
are followed by a comma.
Page 38 of 136
Page 39 of 136
9 A database has been designed to store data about salespersons and the products they have sold.

The following facts help to define the structure of the database:

• each salesperson works in a particular shop


• each salesperson has a unique first name
• each shop has one or more salespersons
• each product which is sold is manufactured by one company only
• each salesperson can sell any of the products
• the number of products that each salesperson has sold is recorded

The table ShopSales was the first attempt at designing the database.

FirstName Shop ProductName NoOfProducts Manufacturer


Nick TX television set 3 SKC
refrigerator 2 WP
digital camera 6 HKC
Sean BH hair dryer 1 WG
electric shaver 8 BG
John TX television set 2 SKC
mobile phone 8 ARC
digital camera 4 HKC
toaster 3 GK

(a) State why the table is not in First Normal Form (1NF).

...................................................................................................................................................

...............................................................................................................................................[1]

9608/12/M/J/15 Page 40 of 136


(b) The database design is changed to:

SalesPerson (FirstName, Shop)

SalesProducts (FirstName, ProductName, NoOfProducts, Manufacturer)

Using the data given in the first attempt table (ShopSales), show how these data are now
stored in the revised table designs.

Table: SalesPerson

FirstName Shop

Table: SalesProducts

FirstName ProductName NoOfProducts Manufacturer

[3]

9608/12/M/J/15 Page 41 of 136


(c) (i) A relationship between the two tables has been implemented.

Explain how this has been done.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(ii) Explain why the SalesProducts table is not in Third Normal Form (3NF).

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(iii) Write the table definitions to give the database in 3NF.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

9608/12/M/J/15 Page 42 of 136


8 A school stores a large amount of data. This includes student attendance, qualification, and
contact details. The school’s software uses a file-based approach to store this data.

(a) The school is considering changing to a DBMS.

(i) State what DBMS stands for.

.......................................................................................................................................[1]

(ii) Describe two ways in which the Database Administrator (DBA) could use the DBMS
software to ensure the security of the student data.

1 ........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

2 ........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[4]

(iii) A feature of the DBMS software is a query processor.

Describe how the school secretary could use this software.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(iv) The DBMS has replaced software that used a file-based approach with a relational
database.

Describe how using a relational database has overcome the previous problems
associated with a file-based approach.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

9608/12/M/J/16 Page 43 of 136


(b) The database design has three tables to store the classes that students attend.

STUDENT(StudentID, FirstName, LastName, Year, TutorGroup)

CLASS(ClassID, Subject)

CLASS-GROUP(StudentID, ClassID)

Primary keys are not shown.

There is a one-to-many relationship between CLASS and CLASS–GROUP.

(i) Describe how this relationship is implemented.

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(ii) Describe the relationship between CLASS-GROUP and STUDENT.

.......................................................................................................................................[1]

(iii) Write an SQL script to display the StudentID and FirstName of all students who are
in the tutor group 10B. Display the list in alphabetical order of LastName.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[4]

(iv) Write an SQL script to display the LastName of all students who attend the class whose
ClassID is CS1.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[4]

9608/12/M/J/16 Page 44 of 136


5 (a) A Database Management System (DBMS) provides the following features.

Draw a line to match each feature with its description.

Feature Description

A file or table containing all the details of the


database design
Data dictionary

Data design features to ensure the validity


of data in the database

Data security

A model of what the database will look like,


although it may not be stored in this way

Data integrity Methods of protecting the data including


the uses of passwords and different access
rights for different users of the database

[3]

A school stores a large amount of data that includes student attendance, qualification and contact
details. The school is setting up a relational database to store these data.

(b) The school needs to safeguard against any data loss.

Describe three factors to consider when planning a backup procedure for the data.

Justify your decisions.

1 ................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

2 ................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

3 ................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[6]
9608/13/M/J/16 Page 45 of 136
(c) The database design has three tables to store the qualifications and grades each student has
attained. The following is a sample of the data from each table.

STUDENT

StudentID FirstName LastName Tutor

001AT Ahmad Tan 11A

003JL Jane Li 11B

011HJ Heather Jones 10A

QUALIFICATION

QualCode Level Subject

CS1 IGCSE Computer Science

MT9 IGCSE Maths

SC12 IGCSE Science

STUDENT-QUALIFICATION

QualCode StudentID Grade DateOfAward

SC12 011HJ A 31/8/2014

SC12 003JL C 31/8/2014

CS1 003JL B 31/8/2014

(i) Draw an Entity-Relationship (E-R) diagram to show the relationships between these
three tables.

[2]

(ii) State the type of relationship that exists between STUDENT and
STUDENT-QUALIFICATION.

.......................................................................................................................................[1]

9608/13/M/J/16 Page 46 of 136


(iii) Describe how the relationship between QUALIFICATION and
STUDENT-QUALIFICATION is implemented.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(d) (i) The database will store each student’s date of birth.

Write an SQL script to add a date of birth attribute to the appropriate table.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(ii) Write an SQL script to display the StudentID, Grade and DateOfAward for the
QualCode value of SC12.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

(iii) Write an SQL script to display the FirstName and LastName and QualCode for all
STUDENT-QUALIFICATIONs for which the Grade value is A.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[4]
9608/13/M/J/16 Page 47 of 136
1 Some shops belong to the Rainbow Retail buying group. They buy their goods from one or more
suppliers.

Each shop has:

• a unique shop ID
• a single retail specialism (for example, food, electrical, garden).

Each supplier has:

• a unique supplier ID
• a similar single specialism recorded.

Rainbow Retail creates a relational database to record data about the shops and their suppliers.

The entity-relationship (E-R) diagram for the relationship between the SHOP and SUPPLIER tables
is shown.

SHOP SUPPLIER

(a) Explain what the degree of relationship is between the entities SHOP and SUPPLIER.

...................................................................................................................................................

...............................................................................................................................................[1]

The database design is as follows:

SHOP(ShopID, ShopName, Location, RetailSpecialism)

SUPPLIER(SupplierID, SupplierName, ContactPerson, RetailSpecialism)

SHOP-SUPPLIER(ShopID, SupplierID)

The SHOP–SUPPLIER table stores the suppliers that each shop has previously used.

Primary keys are not shown.

(b) (i) Label the entities and draw the relationships to complete the revised E-R diagram.

SUPPLIER

[3]

9608/12/M/J/17 Page 48 of 136


(ii) Complete the following table to show for each database table:

• the primary key


• the foreign key(s) (if any):
° Each table may contain none, one or more foreign key(s).
° For a table with no foreign key, write ‘None’.
• an explanation for the use of any foreign key.

Table Primary key Foreign key(s) Explanation


(if any)

SHOP

SUPPLIER

SHOP–SUPPLIER

[5]

(iii) The database designer has implemented SUPPLIER.ContactPerson as a secondary


key.

Describe the reason for this.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(c) (i) Write an SQL query to display the shop ID and location of all shops with a ‘GROCERY’
specialism.

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

(ii) The existing shop with ID 8765 has just used the existing supplier SUP89 for the first
time.

Write an SQL script to add this data to the database.

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

9608/12/M/J/17 Page 49 of 136


1 A hospital is divided into two areas, Area A and Area B. Each area has several wards. All the ward
names are different.

A number of nurses are based in Area A. These nurses always work on the same ward. Each
nurse has a unique Nurse ID of STRING data type.

A-NURSE A-WARD

(a) Describe the relationship shown above.

...................................................................................................................................................

...............................................................................................................................................[1]

(b) A relational database is created to store the ward and nurse data. The two table designs for
Area A are:

A-WARD(WardName, NumberOfBeds)

A-NURSE(NurseID, FirstName, FamilyName, ...........................................................)

(i) Complete the design for the A-NURSE table. [1]

(ii) Explain how the relationship in part (a) is implemented.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(c) In Area B of the hospital, there are a number of wards and a number of nurses.

Each Area B ward has a specialism.

Each Area B nurse has a specialism.

A nurse can be asked to work in any of the Area B wards where their specialism matches with
the ward specialism.

The relationship for Area B of the hospital is:

B-NURSE B-WARD

(i) Explain what the degree of relationship is between the entities B-NURSE and B-WARD.

...........................................................................................................................................

.......................................................................................................................................[1]

9608/13/M/J/17 Page 50 of 136


(ii) The design for the Area B data is as follows:

B-NURSE(NurseID, FirstName, FamilyName, Specialism)

B-WARD(WardName, NumberOfBeds, Specialism)

B-WARD-NURSE( ............................................................................................................ )

Complete the attributes for the third table. Underline its primary key. [2]

(iii) Draw the relationships on the entity-relationship (E-R) diagram.

B-NURSE B-WARD

B-WARD-NURSE

[2]

(d) Use the table designs in part (c)(ii).

(i) Write an SQL query to display the Nurse ID and family name for all Area B nurses with a
specialism of ‘THEATRE’.

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[3]

(ii) Fatima Woo is an Area B nurse with the nurse ID of 076. She has recently married, and
her new family name is Chi.

Write an SQL command to update her record.

UPDATE .............................................................................................................................

SET ....................................................................................................................................

WHERE ...............................................................................................................................
[3]

9608/13/M/J/17 Page 51 of 136


7 A social media website has a relational database, WEBDATA, that stores the site’s information.

The database has three tables to store users’ details, and details of the images and text that they
post.

USER(UserName, FirstName, SecondName, DateOfBirth)


PHOTO(PhotoID, UserName, Comment, UploadDate)
TEXTPOST(PostID, UserName, DateOfPost, TheText)

(a) (i) Explain how the relationship between the tables USER and PHOTO has been implemented.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(ii) Draw the entity-relationship (E-R) diagram to show the relationships between the three
tables.

[2]

(b) A database administrator decides to enforce referential integrity.

Use an example from the database WEBDATA to explain what is meant by referential
integrity.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

9608/12/M/J/18 Page 52 of 136


(c) The database has been normalised to Third Normal Form (3NF).

Define the three stages of database normalisation.

1NF ............................................................................................................................................

...................................................................................................................................................

2NF ............................................................................................................................................

...................................................................................................................................................

3NF ............................................................................................................................................

...................................................................................................................................................
[3]

(d) The following shows sample data from the USER table.

UserName FirstName SecondName DateOfBirth

gem123 John Smith 01/01/1995

purpleSky Muhammed Ali 23/02/1956

OpenWindow Sunny Amir 03/03/1997

bluebird127 Raziya Bello 04/03/1982

(i) Write an SQL script to create the USER table.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[5]

9608/12/M/J/18 Page 53 of 136


(ii) The database administrator needs to alter the USER table. A new field, Country, needs
to be added.

Write an SQL script to add the field Country to the USER table.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

9608/12/M/J/18 Page 54 of 136


2 A company writes applications (apps) for smartphones. The company has a relational database,
PURPLEGAME, which stores the information for one of its online game apps.

The database has three tables to store player’s details, dates when they have logged into the app
and in-app purchase details.

LOGIN(LoginID, PlayerID, Date)

PURCHASE(PurchaseID, PlayerID, PurchaseDate, Cost)

PLAYER(PlayerID, PlayerName, SkillLevel)

(a) Draw the entity-relationship (E-R) diagram to show the relationships between the three tables.

[2]

(b) The database manager is concerned about data integrity.

State what is meant by data integrity. Give an example of how the manager can ensure data
integrity in the PURPLEGAME database.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[2]

9608/13/M/J/18 Page 55 of 136


(c) The database designer states that the PURPLEGAME database is in Third Normal Form (3NF).

Tick (3) one box to indicate whether this statement is true or false.

True False

Justify your choice.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

(d) (i) The following table shows some sample data for the PLAYER table.

PlayerID PlayerName SkillLevel


fly918 Kylie 3
elephant11 Mehrdad 9
candy22 Suzi 15
greenGrass Jason 22

Write an SQL script to create the PLAYER table.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[5]

9608/13/M/J/18 Page 56 of 136


(ii) The table, PLAYER, needs to be altered. A new field, DateOfBirth, needs to be added.

Write an SQL script to add the DateOfBirth field to the PLAYER table.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

9608/13/M/J/18 Page 57 of 136


5

(ii) The software company decides to use a database to overcome the limitations of a
file-based system. Some of these limitations are addressed through the logical schema.

Name and describe two levels of the schema of a database.

Name 1 ..............................................................................................................................

Description ........................................................................................................................

...........................................................................................................................................

Name 2 ..............................................................................................................................

Description ........................................................................................................................

...........................................................................................................................................
[4]

© UCLES 2019 9608/11/M/J/19 Page 58 of 136


6

(c) The database has the following tables:

CUSTOMER(CustomerID, CompanyName)

SOFTWARE(SoftwareID, SoftwareName, OperatingSystem, Description)

LICENCE(LicenceID, CustomerID, SoftwareID, DateOfPurchase,


LicenceType, Cost, ExpiryDate)

(i) Identify the type of relationship that exists between the tables CUSTOMER and LICENCE.

...........................................................................................................................................

..................................................................................................................................... [1]

(ii) Describe how the relationship is created between the tables CUSTOMER and LICENCE.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

(iii) The company needs a list of all software licences that have an expiry date on or before
31/12/2019.

Write an SQL query to return the fields CustomerID, SoftwareID, LicenceType,


Cost and ExpiryDate for all licences that expire on, or before 31/12/2019. Group the
output by CustomerID, and in ascending order of cost.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [5]

© UCLES 2019 9608/11/M/J/19 Page 59 of 136


11

5 Moheem is creating a relational database to store data about his customers.

(a) Moheem has been told a relational database addresses some of the limitations of a file-based
approach by reducing data redundancy.

(i) State what is meant by the term data redundancy.

...........................................................................................................................................

..................................................................................................................................... [1]

(ii) Explain how a relational database can help to reduce data redundancy.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [3]

(b) Moheem uses a Database Management System (DBMS) to ensure the security and integrity
of the data.

(i) Explain the difference between security and integrity.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

(ii) Name and describe two security features provided by a DBMS.

Feature 1 ...........................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

Feature 2 ...........................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................
[4]
© UCLES 2019 9608/12/M/J/19 Page 60 of 136
12

(iii) The DBMS provides software tools for the database developer.

Fill in the names of the missing software tools in the following statements.

A ..................................................................... allows a developer to extract data from a


database.

A ..................................................................... enables a developer to create user-friendly


forms and reports.
[2]

© UCLES 2019 9608/12/M/J/19 Page 61 of 136


7

3 A company uses a relational database, EMPLOYEES, to store data about its employees and
departments.

(a) The company uses a Database Management System (DBMS).

(i) The DBMS has a data dictionary.

Describe what the data dictionary stores.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

(ii) The DBMS has a query processor.

Describe the purpose of a query processor.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

(b) Relationships are created between tables using primary and foreign keys.

Describe the role of a primary and a foreign key in database relationships.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2019 9608/13/M/J/19 Page 62 of 136


8

(c) In the company:

• An employee can be a manager.


• A department can have several managers and several employees.
• An employee can only belong to one department.

The EMPLOYEES database has three tables:

EMPLOYEE_DATA(EmployeeID, FirstName, LastName, DateOfBirth, Gender,


DepartmentNumber)
DEPARTMENT(DepartmentNumber, DepartmentName)
DEPARTMENT_MANAGER(DepartmentNumber, EmployeeID, role)

Complete the entity-relationship (E-R) diagram for the EMPLOYEES database.

EMPLOYEE_DATA

DEPARTMENT_MANAGER DEPARTMENT

[3]

(d) Give three reasons why the EMPLOYEES database is fully normalised.

1 ................................................................................................................................................

...................................................................................................................................................

2 ................................................................................................................................................

...................................................................................................................................................

3 ................................................................................................................................................

...................................................................................................................................................
[3]

© UCLES 2019 9608/13/M/J/19 Page 63 of 136


9

(e) Part of the EMPLOYEE_DATA table is shown.

EmployeeID FirstName LastName DateOfBirth Gender DepartmentNumber


156FJEK Harvey Kim 12/05/1984 Male S1
558RRKL Catriona Moore 03/03/1978 Female F2
388LMDV Oscar Ciao 01/01/1987 Male F2

(i) Write a Data Definition Language (DDL) statement to create the EMPLOYEES database.

...........................................................................................................................................

..................................................................................................................................... [1]

(ii) Write a DDL statement to define the table EMPLOYEE_DATA, and declare EmployeeID
as the primary key.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [5]

© UCLES 2019 9608/13/M/J/19 Page 64 of 136


10

(iii) Write a Data Manipulation Language (DML) statement to return the first name and last
name of all female employees in the department named Finance.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [5]

© UCLES 2019 9608/13/M/J/19 Page 65 of 136


12

7 A driving school teaches people how to drive cars. The school has a relational database,
DRIVING_SCHOOL, to store information about instructors, students, lessons and the cars used by
instructors.

INSTRUCTOR(InstructorID, FirstName, LastName, DateOfBirth, Level)

CAR(Registration, Make, Model, EngineSize)

INSTRUCTOR_CAR(InstructorID, Registration)

STUDENT(StudentID, FirstName, LastName, DateOfBirth, Address1)

LESSON(LessonID, StudentID, InstructorID, LessonDate, LessonTime)

(a) Give two benefits to the driving school of using a relational database instead of a flat file.

1 .................................................................................................................................................

...................................................................................................................................................

2 .................................................................................................................................................

...................................................................................................................................................
[2]

(b) Complete the entity-relationship diagram for the database DRIVING_SCHOOL.

INSTRUCTOR INSTRUCTOR_CAR

LESSON CAR

STUDENT

[4]

© UCLES 2020 9608/11/M/J/20 Page 66 of 136


13

(c) The table shows some sample data for the table INSTRUCTOR.

InstructorID FirstName LastName DateOfBirth Level


Ins01 Jayden Han 05/06/1974 1
Ins02 Freda Choi 06/02/1978 2
Ins03 Kelly Kim 01/12/1966 1
Ins04 Santana Thompson 09/09/1985 3

Complete the Data Definition Language (DDL) statement to create the table INSTRUCTOR.

………………………………………………………………………… TABLE INSTRUCTOR(

InstructorID VARCHAR(5),

FirstName VARCHAR(15),

LastName VARCHAR(15),

DateOfBirth DATE,

Level ………………………………………………………………………… ,

………………………………………………………………………… (InstructorID)

);
[3]

(d) The table STUDENT needs an additional field to store the student’s telephone number, for
example 012-3456.

Write a Data Definition Language (DDL) statement to add the new field to the table STUDENT.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(e) Write a Data Manipulation Language (DML) statement to return the date and time of all future
lessons booked with the instructor whose InstructorID is Ins01.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]
© UCLES 2020 9608/11/M/J/20 Page 67 of 136
11

6 A software development company has a relational database, SOFTWARE_MANAGEMENT. The


database stores details of the customers who have purchased software, as well as the software
and licences that customers have purchased.

The SOFTWARE_MANAGEMENT database has the following tables:

CUSTOMER_DETAILS(CustomerID, CompanyName, Address1, Address2, City)

SOFTWARE_PURCHASED(SoftwareName, SoftwareDescription, CustomerID,


LicenceType, LicenceCost, RenewalDate)

(a) Explain why this database is not in Third Normal Form (3NF). Refer to the tables in your
answer.

Do not attempt to normalise the tables.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(b) Give an example from the database SOFTWARE_MANAGEMENT for each of the following
database terms.

Term Example

Entity

Foreign key

Attribute

[3]

© UCLES 2020 9608/12/M/J/20 Page 68 of 136


12

(c) The company also develops computer games. They extend the relational database
SOFTWARE_MANAGEMENT by adding a new table. The new table, GAME_DEVELOPMENT,
stores details about the games and the software development teams creating them.

The table shows example data in GAME_DEVELOPMENT.

GameName Genre TeamNumber DevelopmentStage ManagerID

Bunny Hop Platform 4 Analysis 23KP

Fried Eggs Retro 2 Programming stage 1 9RTU

Create‑a‑game Action 1 Acceptance testing 11TF

(i) Complete the Data Definition Language (DDL) statement to create the table
GAME_DEVELOPMENT.

CREATE ………………………………………………………… ………………………………………………………… (

GameName VarChar,

Genre VarChar,

………………………………………………………… ………………………………………………………… ,

DevelopmentStage VarChar,

ManagerID VarChar,

………………………………………………………… (GameName)

);
[5]

(ii) Another table, PRODUCT_MANAGER, is created.

PRODUCT_MANAGER(ManagerID, FirstName, LastName)

Complete the Data Manipulation Language (DML) statement to return the game name,
genre and team number of all games managed by the product manager with the first
name ‘James’ and the last name ‘Fitz’.

………………………………………………………… GameName, Genre, TeamNumber

FROM GAME_DEVELOPMENT, PRODUCT_MANAGER

WHERE PRODUCT_MANAGER.FirstName = "James"

AND PRODUCT_MANAGER.LastName = "Fitz"

AND …………………………………………………………………………………………………

= …………………………………………………………………………………………………… ;
[3]
© UCLES 2020 9608/12/M/J/20 Page 69 of 136
10

6 Sheila creates a relational database for her hotel using a Database Management System (DBMS).

(a) Draw one line from each database term to its most appropriate description.

Database Term Description

A field in one table that links to a primary key in another table

Primary key
A collection of records and fields

Attribute
The type of data that is being stored

Foreign key A unique identifier for each tuple

A data item, represented as a field within a table


Entity

The concept or object in the system that we want to model


and store information about

[4]

(b) Identify three tasks that Sheila can perform using the DBMS developer interface.

1 ................................................................................................................................................

2 ................................................................................................................................................

3 ................................................................................................................................................
[3]

© UCLES 2020 9608/13/M/J/20 Page 70 of 136


11

(c) Sheila creates the database HOTEL with the following table structure:

ROOM(RoomNumber, RoomType)

BOOKING(BookingID, RoomNumber, CustomerID, StartDate)

CUSTOMER(CustomerID, FirstName, LastName, Address, Tel_Num)

(i) The following table shows some sample data for the table ROOM.

RoomNumber RoomType
1 Standard
2 Double
3 Executive
4 Standard

Complete the Data Definition Language (DDL) statement to create the table ROOM.

................................................ TABLE ROOM(

RoomNumber Integer,

RoomType ................................................,

................................................ (RoomNumber)

);
[3]

(ii) Room number 5 is a Double room.

Complete the Data Manipulation Language (DML) statement to add the details for room
number 5 to the table ROOM.

INSERT ................................................ ROOM

VALUES(......................................................................................................);
[2]

(iii) The table BOOKING needs an additional field to store the number of nights (for example,
3) a customer is staying.

Write a Data Definition Language (DDL) statement to add the new field to the table
BOOKING.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]
© UCLES 2020 9608/13/M/J/20 Page 71 of 136
12

7 Xiaoming created the following logo using bitmapped graphics software.

PJF
Interiors

(a) Describe how one typical feature of bitmapped graphics software was used to create the
logo.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

(b) The finished logo is 160 pixels wide and 160 pixels high. The image has a colour depth of
3 bytes per pixel.

Calculate an estimate of the file size for the logo. Give your answer in kilobytes. Show your
working.

Working .....................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Answer ........................................................ KB
[3]

(c) Xiaoming needs to use his logo on his business card, on his website and on large display
boards. He is told that he should have created a vector graphic logo instead of a bitmapped
graphic logo.

Describe one benefit of creating a vector graphic logo instead of a bitmapped graphic logo.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [2]

© UCLES 2020 9608/13/M/J/20 Page 72 of 136


9 A health club offers classes to its members. A member needs to book into each class in advance.

(a) The health club employs a programmer to update the class booking system. The programmer
has to decide how to store the records. The choice is between using a relational database or
a file-based approach.

Give three reasons why the programmer should use a relational database.

1 ................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

2 ................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

3 ................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[6]

(b) The programmer decides to use three tables: MEMBER, BOOKING and CLASS.

Complete the Entity-Relationship (E-R) diagram to show the relationships between these
tables.

MEMBER CLASS

BOOKING

[2]

9608/12/O/N/16 Page 73 of 136


(c) The CLASS table has primary key ClassID and stores the following data:

ClassID Description StartDate ClassTime NoOfSessions AdultsOnly

DAY01 Yoga beginners 12/01/2016 11:00 5 TRUE

EVE02 Yoga beginners 12/01/2016 19:00 5 FALSE

DAY16 Circuits 30/06/2016 10:30 4 FALSE

Write an SQL script to create the CLASS table.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[6]

9608/12/O/N/16 Page 74 of 136


1 (a) Five descriptions and seven relational database terms are shown below.

Draw a line to link each description to its correct database term.

Description Database term

Any object, person or thing about which


it is possible to store data
Secondary key

Candidate key
Dataset organised in rows and columns;
the columns form the structure and the
rows form the content
Entity

Any attribute or combination of attributes Foreign key


that can act as a unique key

Primary key
Attribute(s) in a table that link to the
primary key in another table to form a
relationship Table

Tuple
Attribute or combination of attributes that
is used to uniquely identify a record

[5]

(b) Explain what is meant by referential integrity.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

9608/13/O/N/16 Page 75 of 136


7 A company takes customer service for its clients very seriously.

The client
• The client names are unique.
A visit
• The company arranges a date for a visit to gather feedback from a client.
• A visit to a client never takes more than one day.
• Over time, the client receives many visits.
Staff (Interviewers)
• One or more staff attend the visit.
• If there is more than one staff member visiting, each performs a separate interview.
Interviews
• Each interview is classified as either ‘general’ or by some specialism, for example, marketing,
customer service or sales.
• A report is produced for each interview, InterviewText.
• Each interview is conducted by a single staff member.

The client, visit, staff and interview data will be stored in a relational database.

(a) (i) Underline the primary key for each table in the following suggested table designs.

STAFF(StaffID, StaffName, Department)

CLIENT(ClientName, Address, Town)

VISIT(ClientName, VisitDate)

INTERVIEW(ClientName, VisitDate, StaffID, SpecialistFocus, InterviewText)


[3]

(ii) For each of the pairs of entities, A, B and C, draw the relationship between the two
entities.

A CLIENT VISIT

B VISIT INTERVIEW

C INTERVIEW STAFF
[3]

9608/12/O/N/17 Page 76 of 136


(b) The company decides to produce a visit report, VisitReportText, for each visit made.

This text will be produced from the one or more interview texts obtained at the visit.

State how one or more of the given table designs can be changed to add this attribute.

...................................................................................................................................................

...............................................................................................................................................[1]

(c) Client ABC Holdings are now trading under the name of Albright Holdings.

(i) Write an SQL script to update this client’s record in the database.

UPDATE .............................................................................................................................

SET ....................................................................................................................................

WHERE ...............................................................................................................................
[3]
(ii) Describe why this update could cause problems with the existing data stored.

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

(d) Write an SQL script to display the Staff ID of each member of staff who performed an interview
when they visited New Age Toys on 13/10/2016.

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

(e) At present, all interviews are performed in the UK. Many clients now operate in other countries
in Europe. The company wants to perform interviews with the client’s staff in other countries.
Not all interview staff are willing to travel outside of the UK.

State how one or more of the table designs should be revised to store this information.

...................................................................................................................................................

...............................................................................................................................................[1]

9608/12/O/N/17 Page 77 of 136


7 A clinic is staffed by several doctors. The clinic serves thousands of patients. Each day and at any
one time, there is only one doctor in the clinic available for appointments.

The clinic stores patient, doctor and appointment data in a relational database.

(a) (i) Underline the primary key for each table in the following suggested table designs.

PATIENT(PatientID, PatientName, Address, Gender)

DOCTOR(DoctorID, Gender, Qualification)

APPOINTMENT(AppointmentDate, AppointmentTime, DoctorID, PatientID)


[2]

(ii) Complete the following entity-relationship (E-R) diagram for this design.

[2]

(b) The doctors are concerned that many patients make appointments but do not attend them.

Describe the changes to the table designs that could be made to store this information.

...................................................................................................................................................

...............................................................................................................................................[2]

9608/13/O/N/17 Page 78 of 136


(c) The doctors are about to set up a new clinic in the neighbouring village, SITE-B.

The original location is identified as SITE-A.

A new table is designed to store the ID of the doctor who is able to work at each site.

DOCTOR-AVAILABILITY(DoctorID, Site)

Five entries stored in the table are:

DoctorID Site
098 SITE-A
074 SITE-A
117 SITE-B
098 SITE-B
033 SITE-B

(i) State what this data shows about the availability of the doctor with the ID of 098.

...........................................................................................................................................

.......................................................................................................................................[1]

(ii) Opening a new clinic in the neighbouring village will not require any additional table for
storing appointments. It will need a change to the existing appointment table design.

Show the revised APPOINTMENT table.

APPOINTMENT( ................................................................................................................

................................................................................................................................... ) [1]

(d) The doctor with the ID of 117 has recently been allocated a new DoctorID of 017.

(i) Write an SQL script to update this doctor’s record in the database.

UPDATE .............................................................................................................................

SET .....................................................................................................................................

WHERE ...............................................................................................................................
[3]

(ii) Describe why this update could cause problems with the existing data stored.

...........................................................................................................................................

...........................................................................................................................................

.......................................................................................................................................[2]

9608/13/O/N/17 Page 79 of 136


(e) Write an SQL script to display the date and time of all appointments made by the patient with
the PatientID of 556.

...................................................................................................................................................

...................................................................................................................................................

...............................................................................................................................................[3]

9608/13/O/N/17 Page 80 of 136


11

(d) The bank uses a relational database, ACCOUNTS, to store the information about customers
and their accounts.

The database stores the customer’s first name, last name and date of birth.

The bank has several different types of account. Each account type has a unique ID number,
name (for example, regular or saving) and bonus (for example, $5.00, $10.00 or $15.00).

A customer can have more than one account.

Each customer’s account has its own ID number and stores the amount of money the
customer has in that account.

The bank creates a normalised, relational database to store the required information. There
are three tables:

• CUSTOMER
• ACCOUNT_TYPE
• CUSTOMER_ACCOUNT

(i) Write the attributes for each table to complete the database design for the bank.

CUSTOMER( .......................................................................................................................

...........................................................................................................................................

.........................................................................................................................................)

ACCOUNT_TYPE( ..............................................................................................................

...........................................................................................................................................

.........................................................................................................................................)

CUSTOMER_ACCOUNT( ......................................................................................................

...........................................................................................................................................

.........................................................................................................................................)
[3]

(ii) Identify the primary key for each table that you designed in part (d)(i).

CUSTOMER .........................................................................................................................

ACCOUNT_TYPE ................................................................................................................

CUSTOMER_ACCOUNT ........................................................................................................
[2]

(iii) Identify one foreign key in one of the tables that you designed in part (d)(i).

Table name ........................................................................................................................

Foreign key .......................................................................................................................


[1]
© UCLES 2019 9608/11/O/N/19 Page 81 of 136
12

(iv) The following table has definitions of database terms.

Write the correct database term in the table for each definition.

Definition Term

All the data about one entity

The data in one row of a table

A column or field in a table


[3]

© UCLES 2019 9608/11/O/N/19 Page 82 of 136


6

4 Anushka needs to store information about bookings at a sports club.

(a) Anushka has a file-based storage system. She wants a relational database.

(i) Describe the features of a relational database that address the limitations of Anushka’s
file-based system.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [4]

(ii) The relational database design needs to be normalised. The following statements
describe the three stages of database normalisation.

Complete the statements by filling in the missing words.

For a database to be in First Normal Form (1NF) there must be no ..................................

groups of attributes.

For a database to be in Second Normal Form (2NF), it must be in 1NF, and contain no

.................................. key dependencies.

For a database to be in Third Normal Form (3NF), it must be in 2NF, and all attributes

must be fully dependent on the .................................. .................................. .


[4]

© UCLES 2019 9608/12/O/N/19 Page 83 of 136


7

(b) The normalised relational database, SPORTS_CLUB, has the following table design.

MEMBER(MemberID, FirstName, LastName, MembershipType)

SESSION(SessionID, Description, SessionDate, SessionTime, NumberMembers)

TRAINER(TrainerID, TrainerFirstName, TrainerLastName)

MEMBER_SESSION(MemberID, SessionID)

SESSION_TRAINER(SessionID, TrainerID)

(i) Anushka has designed an entity-relationship (E-R) diagram for SPORTS_CLUB.

Complete the entity-relationship (E-R) diagram.

MEMBER SESSION

MEMBER_SESSION SESSION_TRAINER

TRAINER

[2]

(ii) Anushka first needs to create the database that she has designed.

Write a Data Definition Language (DDL) statement to create the SPORTS_CLUB


database.

...........................................................................................................................................

..................................................................................................................................... [1]

© UCLES 2019 9608/12/O/N/19 Page 84 of 136


8

(iii) The table shows some sample data for the table SESSION.

SessionID Description SessionDate SessionTime NumberMembers


21PL Pilates junior 04/04/2020 18:00 15
13AE Aerobics senior 04/04/2020 19:00 20
Weightlifting
33WG 04/04/2020 10:00 10
advanced

Write a DDL script to create the table SESSION.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [5]

(iv) Write a Data Manipulation Language (DML) script to return the first name and last name
of all members who have Peak membership type.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [3]

© UCLES 2019 9608/12/O/N/19 Page 85 of 136


7

3 A hotel needs to record information about customers and their bookings.

(a) The hotel has two types of room: double and family. Each room has a unique room number.

The hotel stores information about the customers including their name, address and contact
details.

When a customer books a room, they give the start date and the number of nights they want
to stay. If a customer wants more than one room, each room must have a separate booking.
Each booking has an ID number.

The hotel creates a normalised, relational database to store the required information. There
are three tables:

• CUSTOMER
• ROOM
• BOOKING

(i) Complete the database design for the hotel by writing the attributes for each table.

CUSTOMER( .......................................................................................................................

...........................................................................................................................................

........................................................................................................................................ )

ROOM( ...............................................................................................................................

...........................................................................................................................................

........................................................................................................................................ )

BOOKING( .........................................................................................................................

...........................................................................................................................................

........................................................................................................................................ )
[3]

(ii) Identify the primary key for each table that you designed in part (a)(i).

CUSTOMER .........................................................................................................................

ROOM ..................................................................................................................................

BOOKING ...........................................................................................................................
[2]

© UCLES 2019 9608/13/O/N/19 Page 86 of 136


8

(iii) Identify one foreign key in the tables that you designed in part (a)(i).

Table name ........................................................................................................................

Foreign key .......................................................................................................................


[1]

(b) The hotel wants to use a Database Management System (DBMS) to set up and manage the
database.

Describe, using examples, how the hotel can use the following DBMS tools:

Developer interface ..................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Query processor .......................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................
[5]

(c) The following table has four SQL scripts.

Tick (✓) one box in each row to identify whether the script is an example of a Data Definition
Language (DDL) statement or a Data Manipulation Language (DML) statement.

Script DDL DML

CREATE TABLE FILMS

SELECT FilmID FROM FILMS

ALTER TABLE FILMS ADD PRIMARY KEY (FilmID)

CREATE DATABASE MYDATA


[2]

© UCLES 2019 9608/13/O/N/19 Page 87 of 136


3

2 A veterinary surgery cares for sick animals. The surgery has a file-based database that stores
data about the pets, their owners, and appointments made with the surgery.

The surgery wants to upgrade to a relational database.

(a) Explain the reasons why the surgery should upgrade their database.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

(b) The design for the surgery database, SURGERY, is:

PET(PetID, OwnerFirstName, OwnerLastName, PetName, PetBreed,


PetDateOfBirth, TelephoneNumber)

APPOINTMENT(AppointmentID, Date, Time, StaffID, PetID)

(i) Give one reason why the database design for SURGERY is not in Third Normal Form
(3NF).

...........................................................................................................................................

..................................................................................................................................... [1]

© UCLES 2020 9608/11/O/N/20 Page 88 of 136


4

(ii) The database needs to be normalised to 3NF. A pet may have more than one owner and
an owner may have more than one pet.

The appointment table does not need to change and has been repeated below.

Give the name and attributes of three additional tables in 3NF. Identify the primary
key(s) in each table.

APPOINTMENT(AppointmentID, Date, Time, StaffID, PetID)

Table 1 ...............................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

Table 2 ...............................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

Table 3 ...............................................................................................................................

...........................................................................................................................................

...........................................................................................................................................
[4]

(c) Part of the table APPOINTMENT is shown. The veterinary surgery uses Data Manipulation
Language (DML) statements to search for appointments.

AppointmentID Date Time StaffID PetID


222010 02/02/2021 12:40 JK1 20CF
222011 02/02/2021 12:40 PP2 10DT
222012 02/02/2021 12:50 JK1 9RR
222013 02/02/2021 13:00 JK1 7MR

(i) Identify the industry standard language that provides both DML and Data Definition
Language (DDL) statements.

...........................................................................................................................................

..................................................................................................................................... [1]

© UCLES 2020 9608/11/O/N/20 Page 89 of 136


5

(ii) Write a DDL statement to update the table APPOINTMENT and define AppointmentID
as the primary key.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

(iii) Complete the DML script to display the times and Pet IDs of all appointments on
02/02/2021 with staff ID of ‘JK1’, in descending order of time.

SELECT ........................................................ , ........................................................

FROM APPOINTMENT

WHERE ........................................................ AND ........................................................

ORDER BY Time ........................................................ ;


[3]

(d) New pet owners complete a paper-based form to register their pets at the surgery.

(i) Describe two verification checks that can be carried out when the data from the paper-
based form is entered into the database.

1 ........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

2 ........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................
[4]

© UCLES 2020 9608/11/O/N/20 Page 90 of 136


6

(ii) Appointments can be booked between 09:00 and 16:50 on Monday to Friday.

Describe the ways in which the appointment date and time can be validated to make
sure they are reasonable.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

(e) The surgery has five computers that can all access the database. A copy of the database is
stored centrally.

(i) Complete the description of this type of network model by filling in the missing terms.

The ......................................... model has one ......................................... that stores all

the data for the surgery. The other computers are ......................................... . When a

user requests data, a request is sent to the ......................................... .


[4]

(ii) The surgery wants to keep all data secure. The surgery network is not connected to the
Internet.

Identify two authentication techniques the surgery could use to restrict access to the
data.

1 ........................................................................................................................................

2 ........................................................................................................................................
[2]

© UCLES 2020 9608/11/O/N/20 Page 91 of 136


9

5 A teacher uses a relational database, RESULTS, to store data about her students and their test
results.

(a) Describe the benefits to the teacher of using a relational database instead of a file-based
approach.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

............................................................................................................................................. [4]

(b) The teacher sets up the RESULTS database using a Database Management System (DBMS).

(i) Explain the ways in which the developer interface of a DBMS will help the teacher set up
the database.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

(ii) The DBMS creates a data dictionary for the RESULTS database.

Identify three items that will be included in the data dictionary.

1 ........................................................................................................................................

2 ........................................................................................................................................

3 ........................................................................................................................................
[3]

© UCLES 2020 9608/12/O/N/20 Page 92 of 136


10

(c) The RESULTS database has the following structure:

STUDENT(StudentID, FirstName, LastName, Class, TargetGrade)

TEST(TestID, Topic, MaxMarks)

STUDENT_TEST(StudentID, TestID, Mark)

(i) Complete the following table by giving one example of each database term from the
database RESULTS. Give both the field name and the corresponding table name.

Database term Field name Table name

Primary key

Foreign key

Attribute

[3]

(ii) Tick (✓) one box to identify whether the database RESULTS is in 1NF, 2NF or 3NF.
Justify your choice.

1NF 2NF 3NF

Justification: ......................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [3]

(iii) Complete the Data Manipulation Language (DML) script to display the Student ID, mark
and maximum marks for all tests with the topic of ‘Programming’.

SELECT StudentID, Mark, ........................................................

FROM STUDENT_TEST, ........................................................

........................................................ Topic = "Programming"

AND ........................................................ = ........................................................;


[5]

© UCLES 2020 9608/12/O/N/20 Page 93 of 136


11

(iv) The teacher wants to implement validation to make sure that all data entered into the
database RESULTS are reasonable.

Name three different methods of data validation that can be used in the RESULTS
database. Describe how each method will limit the data that can be entered in this
database.

Method 1 ...........................................................................................................................

Description ........................................................................................................................

...........................................................................................................................................

Method 2 ...........................................................................................................................

Description ........................................................................................................................

...........................................................................................................................................

Method 3 ...........................................................................................................................

Description ........................................................................................................................

...........................................................................................................................................
[6]

(d) The teacher stores the database on the desktop computer in her classroom.

(i) Explain why it is important to keep the database secure.

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

..................................................................................................................................... [2]

(ii) Explain the ways in which the teacher can use data backup and disk mirroring to limit the
amount of data lost in the event of hardware failure.

Data backup

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

Disk mirroring

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................

...........................................................................................................................................
[4]
© UCLES 2020 9608/12/O/N/20 Page 94 of 136
Page 95 of 136
Page 12 Mark Scheme Syllabus Paper
Cambridge International AS/A Level – May/June 2015 9608 12

9 (a) Any one from:

• (ShopSales) table has repeated group (of attributes)


• each sales person has a number of products
• FirstName, Shop would need to be repeated for each record [1]

(b) One mark for SalesPerson table

table: SalesPerson

FirstName Shop

Nick TX

Sean BH

John TX

Page 96 of 136
Page 13 Mark Scheme Syllabus Paper
Cambridge International AS/A Level – May/June 2015 9608 12

table: SalesProducts

FirstName ProductName NoOfProducts Manufacturer

Nick television set 3 SKC

Nick refrigerator 2 WP

Nick digital camera 6 HKC

Sean hair dryer 1 WG

Sean electric shaver 8 BG

John television set 2 SKC

John mobile phone 8 ARC

John digital camera 4 HKC

John toaster 3 GK

(1 mark for FirstName column + 1 mark for remainder of table)


[3]

Page 97 of 136
MMM

Page 14 Mark Scheme Syllabus Paper


Cambridge International AS/A Level – May/June 2015 9608 12

(c) (i) Any two from:

• primary key of SalesPerson table is FirstName


• links to FirstName in SalesProducts table
• FirstName in SalesProductsS table is foreign key [2]

(ii) • There is a non-key dependency


• Manufacturer is dependent on ProductName, (which is not the primary key of the
SalesProducts table) [2]

(iii) SalesPerson (FirstName, Shop)


–SalesProducts (FirstName, ProductName, NoOfProducts) OR
SalesProducts(SalesID, FirstName, ProductName, NoOfProducts)

-Product (ProductName, Manufacturer)

1 mark for correct attributes in SalesProducts and Product tables and 1 mark for
correct identification of both primary keys [2]

Page 98 of 136
Page 7 Mark Scheme Syllabus Paper
Cambridge International AS/A Level – May/June 2016 9608 12

8 (a) (i) Database Management System [1]

(ii) One mark for identifying the way in which the data security is ensured, and one mark
for a further description.

Maximum of two marks per method. Maximum of two methods. [4]

• Issue usernames and passwords...


o stops unauthorised access to the data
o any further expansion e.g. strong passwords / passwords should be changed
regularly etc…
• Access rights / privileges...
o so that only relevant staff / certain usernames can read/edit certain parts of the
data
o can be read only, or full access / read, write and delete
o any relevant example e.g. only class tutors can edit details of pupils in their tutor
group
• Create (regular / scheduled) backups...
o in case of loss/damage to the live data a copy is available
o any relevant example e.g. backing up the attendance registers at the end of
each day and storing the data off-site/to a separate device
• Encryption of data...
o if there is unauthorised access to the data it cannot be understood // needs a
decryption key
o any relevant example e.g. personal details of pupils are encrypted before being
sent over the Internet to examination boards
• Definition of different views...
o composed of one or more tables
o controls the scope of the data accessible to authorised users
o any relevant example e.g. teachers can only see their classes
• Usage monitoring / logging of activity...
o creation of an audit /activity log
o records the use of the data in the database / records operations performed by
all users / all access to the data
o any relevant example, e.g. Track who changed a student’s grade

(iii) Two points from: [2]

• Set up search criteria


• To find / retrieve / return the data that matches the criteria
• Any relevant example e.g. find pupils who were absent on a particular day

Page 99 of 136
Page 8 Mark Scheme Syllabus Paper
Cambridge International AS/A Level – May/June 2016 9608 12

(iv) Three points from: [3]

• By storing data in (separate) linked tables data redundancy is reduced / data


duplication is controlled...
• Compatibility / data integrity issues are reduced as data only needs to be updated
once / is only stored once.
• Unwanted or accidental deletion of linked data is prevented as the DBMS will flag an
error.
• Program - data dependence is overcome.
• Changes made to the structure of the data have little effect on existing programs.
• Ad-hoc / complex queries can be more easily made as the DBMS will have a query
language/ QBE form.
• Unproductive maintenance is eliminated as changes only need to be made once
(rather than changing multiple programs).
• Fields can be added or removed without any effect on existing programs (that do not
use these fields).
• Security / privacy of the data is improved as each application only has access to the
fields it needs.
• There is better control of data integrity as the DBMS (uses its Data Dictionary) to
perform validation checks on data entered.

(b) (i) Two points from: [2]

• The Primary Key in CLASS is ClassID


• The Foreign Key of CLASS-GROUP is ClassID.
• The Primary Key of CLASS is also included in CLASS-GROUP as a Foreign Key,
(which links to CLASS table)

(ii) Many-to-one [1]

(iii) One mark per statement. Several statements may be on the same line. [4]

SELECT StudentID, FirstName


FROM STUDENT
WHERE TutorGroup = "10B" // WHERE (TutorGroup = "10B")
ORDER BY LastName ASC;

Page 100 of 136


Page 9 Mark Scheme Syllabus Paper
Cambridge International AS/A Level – May/June 2016 9608 12

(iv) One mark per statement. Several statements may be on the same line. [4]

SELECT STUDENT.LastName
FROM STUDENT, CLASS-GROUP
WHERE ClassID = "CS1" // WHERE (ClassID = "CS1")
AND CLASS-GROUP.StudentID = STUDENT.StudentID;

One mark per statement. Several statements may be on the same line.

SELECT STUDENT.LastName
FROM STUDENT INNER JOIN CLASS-GROUP
ON CLASS-GROUP.StudentID = STUDENT.StudentID
WHERE ClassID = "CS1" // WHERE (ClassID = "CS1");

Page 101 of 136


Page 4 Mark Scheme Syllabus Paper
Cambridge International AS/A Level – May/June 2016 9608 13

5 (a) One mark for each correct line. [3]

Data Dictionary
A file/table containing all the data about the
detail of the database design

Data Security Data design features to ensure the validity of


data in the database

Data Integrity A model of what the database will look like,


although it may not be stored in this way

Methods of protecting the data including the


uses of passwords and different access
rights for different users of the database

(b) One mark for procedure point, one mark for justification. [6]

Maximum three procedures.

• How often should the data be backed up? e.g. at the end of each day
• Justification e.g. student’s progress may be edited each day and should not be lost

• What medium should the data be backed up to? e.g. external hard disk drive
• Justification e.g. it has large enough capacity

• Where should the backups be stored? e.g. off-site


• Justification e.g. so if the building is damaged only the original data are lost

• What is backed up? e.g. only updated files ...


• Justification e.g. There are a large number of files and they are not all updated each day

• When should the backup take place? e.g. overnight


• Justification e.g. the system is not likely to be used then

• Who is responsible for performing the backup?


• Justification e.g. otherwise it may not be done

• Make sure the procedure is written down and understood by staff


• Justification e.g. otherwise some data may not be backed up

Page 102 of 136


Page 5 Mark Scheme Syllabus Paper
Cambridge International AS/A Level – May/June 2016 9608 13

(c) (i) One mark for each correct relationship. [2]

STUDENT STUDENT-
QUALIFICATION
QUALIFICATION

(ii) One-to-many [1]

(iii) Two points from: [2]

• The primary key in the QUALIFICATION table is QualCode.


• The foreign key in the STUDENT-QUALIFICATION table is QualCode.
• The primary key of QUALIFICATION is also included in QualCode.

(d) (i) One mark per statement. Several statements may be on one line. [2]

ALTER TABLE STUDENT


ADD DateOfBirth DATE;

(ii) One mark per statement. Several statements may be on one line. [3]

SELECT StudentID, Grade, DateOfAward


FROM STUDENT-QUALIFICATION
WHERE QualCode = 'SC12';

(iii) One mark per statement. Several statements may be on one line. [4]

SELECT STUDENT.FirstName, STUDENT.LastName, STUDENT-


QUALIFICATION.QualCode
FROM STUDENT, STUDENT-QUALIFICATION
WHERE STUDENT-QUALIFICATION.Grade = 'A'
AND STUDENT.StudentID = STUDENT-QUALIFICATION.StudentID;

Alternative answer:

SELECT FirstName, LastName, STUDENT-QUALIFICATION.QualCode


FROM STUDENT, INNER JOIN STUDENT-QUALIFICATION
ON STUDENT.StudentID = STUDENT-QUALIFICATION.StudentID
WHERE Grade = 'A';

Page 103 of 136


9608/12 Cambridge International AS/A Level – Mark Scheme May/June 2017
PUBLISHED

Question Answer Marks

1(a) Many-to-many relationship 1

1(b)(i) 3

Both entities correctly labelled 1


Correct relationship between SHOP and SHOP-SUPPLIER 1
Correct relationship between SUPPLIER and SHOP-SUPPLIER 1

1(b)(ii) Table Primary key Foreign keys(s) Explanation 5


(if any)
SHOP ShopID None

SUPPLIER SupplierID None

SHOP-SUPPLIER ShopID AND ShopID OR To create a link


SupplierID SupplierID with the SHOP or
SUPPLIER
(or both) table.

• SHOP has primary key ShopID and SUPPLIER has primary key
SupplierID 1
• SHOP-SUPPLIER has primary key ShopID + SupplierID 1
• Both SHOP and SUPPLIER show foreign key as ‘None’ 1
• SHOP-SUPPLIER shows foreign key ShopID or SupplierID 1
• Explanation for SHOP-SUPPLIER foreign key describes ShopID or
SupplierID creating a link 1

1(b)(iii) Two from: Max 2


• The database user will frequently want to search on contact name 1
• The contact name attribute has been indexed 1
• It allows for a fast/faster search using contact name 1

1(c)(i) SELECT ShopID, Location 1 3


FROM SHOP 1
WHERE RetailSpecialism = 'GROCERY'; 1

1(c)(ii) INSERT INTO SHOP-SUPPLIER 1 3


(ShopID, SupplierID) 1
VALUES (8765, 'SUP89'); 1

Page 104 of 136


9608/13 May/June 2017
Cambridge International AS/A Level – Mark Scheme
PUBLISHED

Question Answer Marks

1(a) Many-to-one 1

1(b)(i) A-NURSE(NurseID, FirstName, FamilyName, WardName) 1

1(b)(ii) • The primary key WardName in the A-WARD table 1 2


• links to the foreign key WardName in the A-NURSE table. 1

1(c)(i) Many-to-many relationship 1

1(c)(ii) B-WARD-NURSE(WardName, NurseID) 2

Both attributes (with no additions) 1


Joint primary key correctly underlined 1

1(c)(iii) 2
B-NURSE B-WARD

B-WARD-NURSE

Correct relationship between B-NURSE and B-WARD-NURSE 1


Correct relationship between B-WARD and B-WARD-NURSE 1

1(d)(i) SELECT NurseID, FamilyName 1 3


FROM B-NURSE 1
WHERE Specialism = 'THEATRE'; 1

1(d)(ii) UPDATE B-NURSE 1 3


SET FamilyName = 'Chi' 1
WHERE NurseID = '076'; 1

Page 105 of 136


9608/12
9 Cambridg
ge Internatio
onal AS/A Level
L – Mark Scheme Ma 18
ay/June 201
P
PUBLISHED D

Question Answerr Mark


ks

7(a)(i) 1 mark p er
e bullet 2
• UserName iss the primary key in USSER
• UserName iss (included as) a foreig
gn key in PH
HOTO

7(a)(ii) 1 mark forr each corre


ect relationsship 2

Question Answer Marks

7(b) 1 mark per bullet to max 2 for explanation 3


• Referential integrity is making sure tables do not try to reference data
which does not exist // A value of one attribute of a table exists as a
value of another attribute in a different table
• A primary key cannot be deleted unless all dependent records are
already deleted
• Cascading delete
• A primary key cannot be updated unless all dependent records are
already updated
• Cascading update / edit
• Every foreign key value has a matching value in the corresponding
primary key
• The foreign keys must be the same data type as the corresponding
primary key

1 mark for a suitable example


e.g.
• A UserName cannot be deleted from the USER table if they have a
related photo/textpost
• If UserName is updated in USER table, it must also be updated in
PHOTO and TEXTPOST tables
• Cannot create/edit a record in TEXTPOST / PHOTO without a matching
entry in USER table

Page 106 of 136


9608/12 Cambridge International AS/A Level – Mark Scheme May/June 2018
PUBLISHED

Question Answer Marks

7(c) Max 1 mark from each bulleted group 3

1NF
• No repeated groups of attributes
• All attributes should be atomic
• No duplicate rows

2NF (in 1NF and)


• No partial dependencies

3NF (in 2NF and)


• No non-key dependencies
• No transitive dependencies

7(d)(i) 1 mark per bullet 5


• CREATE TABLE USER and ();
• UserName, FirstName and SecondName as VARCHAR and commas
• DateOfBirth as DATE and comma
• PRIMARY KEY(UserName)
• An appropriate NOT NULL

CREATE TABLE USER(


UserName: varchar(15) NOT NULL,
FirstName: varchar(25),
SecondName: varchar(25),
DateOfBirth: Date,
PRIMARY KEY(UserName)
);

7(d)(ii) 1 mark per bullet 2


• ALTER TABLE USER
• ADD COUNTRY varchar;

ALTER TABLE USER


ADD Country varchar;

Page 107 of 136


9608/13 Cambridge International AS/A Level – Mark Scheme May/June 2018
PUBLISHED

Question Answer Marks

2(a) 1 mark for each correct relationship 2

2(b) 1 mark for description 2


• Ensure data is consistent / accurate // keep data consistent / accurate

1 mark for example from:

e.g.
• Validation rules
• Referential integrity
• Verification
• Input masks
• Setting data types
• Removing redundant data
• Backup data
• Access controls
• Audit trail

2(c) 1 mark for the correct box ticked 3

True False
9

1 mark per bullet for justification, max 2

• No repeated attributes // data is atomic // No partial dependencies (no dual


keys)
• No non-key / transitive dependencies
2(d)(i) 1 mark per bullet 5

• CREATE TABLE PLAYER and ();


• PlayerID and PlayerName as VARCHAR and commas
• SkillLevel as INT and comma
• PRIMARY KEY(PlayerID)
• An appropriate NOT NULL

CREATE TABLE PLAYER(


PlayerID: varchar NOT NULL,
PlayerName: varchar,
SkillLevel: int,
PRIMARY KEY(PlayerID),
);

2(d)(ii) 1 mark per bullet 2

• ALTER TABLE PLAYER


• ADD DateOfBirth Date;

Page 108 of 136


9608/11 Cambridge International AS/A Level – Mark Scheme May/June 2019
PUBLISHED

Question Answer Marks

2(a) 1 mark for each correct term 4

• Commercial Licence
• Free Software Licence
• Shareware Licence
• Open Source Licence

2(b)(i) 1 mark per bullet point to max 3 3

• Data redundancy // data is repeated in more than one file


• Data dependency // changes to data means changes to programs
accessing that data
• Lack of data integrity // entries that should be the same can be different
in different places
• Lack of data privacy // all users have access to all data if a single flat file

2(b)(ii) 1 mark for each correct name, 1 mark for each matching description, max 2 4
marks per level

• External
• The individual’s view(s) of the database

• Conceptual
• Describes the data as seen by the applications making use of the
DBMS
• Describes the ‘views’ which users of the database might have

• Physical / Internal
• Describes how the data will be stored on the physical media

• Logical
• Describes how the relationships will be implemented in the logical
structure of the database

2(c)(i) 1-to-many // 1 customer to/has many licences 1

2(c)(ii) 1 mark per bullet point 2

• CustomerID is the Primary key in CUSTOMER table


• Links to CustomerID as a Foreign key in LICENCE table

© UCLES 2019 Page 4 of 9 Page 109 of 136


9608/11 Cambridge International AS/A Level – Mark Scheme May/June 2019
PUBLISHED

Question Answer Marks

2(c)(iii) 1 mark per bullet point 5

• Select with correct 5 fields


• From LICENCE
• Where ExpiryDate <= '31/12/2019' (any appropriate date type)
• Group by CustomerID
• Order by Cost (with or without ASC, but not DESC)

SELECT CustomerID, SoftwareID, LicenceType,


Cost, ExpiryDate
FROM LICENCE
WHERE ExpiryDate <= '31/12/2019'
GROUP BY CustomerID ORDER BY Cost;

Question Answer Marks

3(a)(i) 1 mark for each advantage, 1 mark for a valid expansion to max 2 × 2 4

• Code is already tested


• «so it is more robust/likely to work

• Saves programming time


• «code does not have to be written/re-written from scratch

• The programmer can use e.g. mathematical functions


• «that s/he may not know how to code

• If there is an improvement in the library routine


• «the program updates automatically

3(a)(ii) 1 mark per bullet point to max 2 2

• A collection of self-contained (shared library) programs


• «that are already compiled
• Linked to the main program during execution
• Library program code is separate from the .EXE file
• Library file only loaded into memory when required at run time
• A DLL file can be made available to several applications (at the same
time)
• If DLL routine is updated the program that uses it will run the update

3(b)(i) 1 mark per bullet point to max 1 1

• Errors can be corrected as they occur


• Can run a partially complete program when developing
• The effect of any change made to the code can be seen immediately

© UCLES 2019 Page 5 of 9 Page 110 of 136


9608/12 Cambridge International AS/A Level – Mark Scheme May/June 2019
PUBLISHED

Question Answer Marks

4(d)(iii) 1 mark for a name and a description of each licence to max 2 2

Commercial Software
• The program is purchased for a fee
• It restricts the number of users/possible time period for use // Limited
number of installations allowed // Software key needed to install
• Source code not provided // source code protected / cannot be edited
• Anyone can purchase/download if agree to the terms

Shareware
• The program is free for a trial period // The (free) program may have
limited functionality // Need to purchase / enter details after trial
• Users do not have access to the source code // source code may not be
edited
• Users may re-distribute the software.

Freeware
• There is no charge for the software
• The software could still be copyrighted
• She can set her own restrictions on what a user can do with the
program

Question Answer Marks

5(a)(i) 1 mark for correct answer 1

Repeated / duplicated data

5(a)(ii) 1 mark per bullet point 3

• Because each record/piece of data is stored once and is referenced by


a (primary) key
• Because data is stored in individual tables
• and the tables are linked by relationships
• By the proper use of Primary and Foreign keys
• By enforcing referential integrity
• By going through the normalisation process

5(b)(i) 1 mark per bullet point 2

• Security ensures that data is safe from unauthorised access // safe from
loss
• Integrity ensures that data is accurate / consistent / up to date

© UCLES 2019 Page 9 of 11 Page 111 of 136


9608/12 Cambridge International AS/A Level – Mark Scheme May/June 2019
PUBLISHED

Question Answer Marks

5(b)(ii) 1 mark for naming, 1 mark for description 4

For example:
• Access rights // User accounts
• Restrict actions (e.g. read / read-write) of specific users // unauthorised
users cannot access the database

• Views
• Restrict which parts of the database specific users can see

• Password // Biometrics // PIN code


• Prevents unauthorised access

• Automatic Backup
• Create regular copies of data in case of loss

• Encryption
• Data is incomprehensible to unauthorised users

5(b)(iii) 1 mark per bullet 2

• Query Processor
• Developer Interface

Question Answer Marks

6(a) 1 mark per gate The OR gates may be re-sequenced 5

Alternatively: 3-input OR gate


1 mark for first three gates, and 2 marks for 3-input OR gate

© UCLES 2019 Page 10 of 11 Page 112 of 136


9608/13 Cambridge International AS/A Level – Mark Scheme May/June 2019
PUBLISHED

Question Answer Marks

2(d) 1 mark per bullet point to max 3 3

For example: He should ...


• ...Keep the client’s personal data private
• ...Involve the client in the development //  Communicate with the client
• Provide the solution that the client asked for
• ...Keep the project running on time // budget
• ...Keep the client informed of any problems/delays

2(e) 1 mark per bullet point to max 3 3

• He uses a compiler because it creates a separate executable file


• The executable means the client cannot access the source code // edit
the program
• The executable means the client does not need the IDE / compiler
• It will (probably) be faster to run the executable than to interpret the
source code every time the program is run

Question Answer Marks

3(a)(i) 1 mark per bullet point 2

• Stores all the information about the database // data about the


data // metadata about the data
• For example, fields, data types, validation, keys

3(a)(ii) 1 mark per bullet point to max 2 2

• Allows the user to enter criteria


• Searches for data which meets the entered criteria
• Organises the results to be displayed to the user

3(b) 1 mark per bullet point to max 2 2

• Primary key uniquely identifies each tuple // Each tuple in the table is


unique
• Primary key can be used as a foreign key in another table
• .. to form a link/relationship between the tables

By example:
• Identification of a primary key in a table
• Describing that primary key in another table as a foreign key

© UCLES 2019 Page 5 of 10 Page 113 of 136


9608/13 Cambridge International AS/A Level – Mark Scheme May/June 2019
PUBLISHED

Question Answer Marks

3(c) 1 mark for each correct link 3

3(d) 1 mark per bullet point to max 3 3

• There are no repeating groups (1NF)


• There are no partial dependencies (2NF)
• There are no non-key dependencies // There are no transitive
dependencies (3NF)

3(e)(i) 1 mark for correct answer 1

CREATE DATABASE EMPLOYEES;

3(e)(ii) 1 mark per bullet 5

• Create table EMPLOYEE_DATA with open and close brackets


• EmployeeID as VarChar restricted to max 7, Gender as a
VarChar restricted to max 6, DepartmentNumber as a VarChar
restricted to max 2
• FirstName and LastName as VarChar (any max lengths must
be reasonable)
• Date of birth as Date
• Declaring EmployeeID as PK

CREATE TABLE EMPLOYEE_DATA (


EmployeeID VarChar(7),
FirstName VarChar,
LastName VarChar,
DateOfBirth Date,
Gender VarChar(6),
DepartmentNumber VarChar(2),
PRIMARY KEY (EmployeeID)
);

© UCLES 2019 Page 6 of 10 Page 114 of 136


9608/13 Cambridge International AS/A Level – Mark Scheme May/June 2019
PUBLISHED

Question Answer Marks

3(e)(iii) 1 mark per bullet 5

• Select FirstName and LastName only


• From both tables
• Where DepartmentName = “Finance”
• AND Gender = “Female”
• Joining tables (either AND, or inner join)

SELECT FirstName, LastName


FROM EMPLOYEE_DATA, DEPARTMENT
WHERE DepartmentName = "Finance"
AND Gender = "Female"
AND DEPARTMENT.DepartmentNumber =
EMPLOYEE_DATA.DepartmentNumber;

Question Answer Marks

4(a) 1 mark per bullet 2

• LDM #300 The (denary) number 300 is loaded (into the register)
• LDD 300 The contents of address 300 are loaded (into the
register)

4(b) 1 mark for JPN correct 3


1 mark for both of ADD and DEC correct
1 mark for LDR correct

Description Jump Arithmetic Data


instruction operation movement

LDR #3 Load the number 3 9


to the Index Register

ADD #2 Add 2 to the 9


Accumulator

JPN 22 Move to the 9


instruction at
address 22

DEC ACC Subtract 1 from the 9


Accumulator

© UCLES 2019 Page 7 of 10 Page 115 of 136


9608/11 Cambridge International AS & A Level – Mark Scheme May/June 2020
PUBLISHED

Question Answer Marks

6(b) 1 mark for correctly naming register, 1 mark for appropriate role 4

• Program counter // PC
• Stores the address of the next instruction to be fetched

• Memory address register // MAR


• Stores the address where data/instruction is to be read from or saved to

• Memory data register // MDR


• Stores data that is about to be written to memory // Stores data that has
just been read from memory

• Current instruction register // CIR


• Stores the instruction that is currently being decoded/executed

Question Answer Marks

7(a) 1 mark per bullet point to max 2 2

• Reduced data redundancy


• Reduced data dependency
• Improved data integrity
• Improved data privacy
• Program-data independence
• Ability to create ad hoc queries

7(b) 1 mark for each correct link 4

INSTRUCTOR INSTRUCTOR_CAR

LESSON CAR

STUDENT

© UCLES 2020 Page 8 of 10 Page 116 of 136


9608/11 Cambridge International AS & A Level – Mark Scheme May/June 2020
PUBLISHED

Question Answer Marks

7(c) 1 mark for each correctly completed statement 3

• CREATE (line 1)
• INTEGER (line 6)
• PRIMARY KEY (line 7)

CREATE TABLE INSTRUCTOR(


InstructorID VARCHAR(5),
FirstName VARCHAR(15),
LastName VARCHAR(15),
DateOfBirth DATE,
Level INTEGER,
PRIMARY KEY (InstructorID)
);

7(d) 1 mark per bullet point 2

• Alter table student


• Add an appropriate identifier with suitable data type

ALTER TABLE STUDENT


ADD TelNum VARCHAR;

7(e) 1 mark per bullet point 4

• Select lesson date and lesson time


• From table LESSON
• Where InstructorID = “Ins01”
• And lesson date is greater than today’s date

SELECT LessonDate, LessonTime


FROM LESSON
WHERE InstructorID = "Ins01"
AND LessonDate > #######;

Question Answer Marks

8(a) 1 mark per bullet point to max 4 4

• Reads/writes data to/from RAM


• … e.g. current data/instructions from a game so the CPU can access it

• Allocates virtual memory


• … when there is insufficient RAM to run a program/game

• Allocates RAM to optimise performance


• Paging
• Segmentation

© UCLES 2020 Page 9 of 10 Page 117 of 136


9608/12 Cambridge International AS & A Level – Mark Scheme May/June 2020
PUBLISHED

Question Answer Marks

6(a) 1 mark per bullet point to max 2 2

• There are partial dependencies in the SOFTWARE_PURCHASED table //


SoftwareDescription is dependent only on SoftwareName and not
both SoftwareName and CustomerID

• There is a non-key dependency in the SOFTWARE_PURCHASED table //


LicenceCost is dependent on LicenceType

6(b) 1 mark for a suitable example for each 3

Term Example

Entity SOFTWARE_PURCHASED //CUSTOMER_DETAILS

CustomerID
Foreign Key
(in SOFTWARE_PURCHASED table)

Attribute Any valid example of an attribute from the tables

6(c)(i) 1 mark for each correct entry (in bold) 5

CREATE TABLE GAME_DEVELOPMENT (


GameName VarChar,
Genre VarChar,
TeamNumber Integer,
DevelopmentStage VarChar,
ManagerID VarChar,
PRIMARY KEY (GameName)
);

6(c)(ii) 1 mark for each correct entry (shown in brackets) 3

SELECT (1) GameName, Genre, TeamNumber


FROM GAME_DEVELOPMENT, PRODUCT_MANAGER
WHERE PRODUCT_MANAGER.FirstName = "James"
AND PRODUCT_MANAGER.SecondName = "Fitz"
AND PRODUCT_MANAGER.ManagerID (1)
= GAME_DEVELOPMENT.ManagerID (1) ;

© UCLES 2020 Page 7 of 9 Page 118 of 136


9608/13 Cambridge International AS & A Level – Mark Scheme May/June 2020
PUBLISHED

Question Answer Marks

6(a) 1 mark for each correct line 4

Database Term Description

A field in one table that links to a primary key


in another table

Primary key
A collection of records and tables

Attribute
The type of data that is being stored

Foreign key
A unique identifier for each tuple

A data item, represented as a field within a


Entity
table

The concept or object in the system that we


want to model and store information about

6(b) 1 mark per task to max 3 3

• Create a table
• Set up relationships between tables
• Create / design a form
• Create / design a report
• Create / design a query (NOT run a query)

6(c)(i) 1 mark for each completed line 3

CREATE TABLE ROOM(


RoomNumber Integer,
RoomType Varchar,
PRIMARY KEY (RoomNumber)
);

6(c)(ii) 1 mark for each completed line 2

INSERT INTO ROOM


VALUES (5,"Double");

© UCLES 2020 Page 7 of 9 Page 119 of 136


9608/13 Cambridge International AS & A Level – Mark Scheme May/June 2020
PUBLISHED

Question Answer Marks

6(c)(iii) 1 mark per bullet point 2

• Alter table booking


• Add number of nights with appropriate field name and data type

ALTER TABLE BOOKING


ADD NumberNights Integer;

Question Answer Marks

7(a) 1 mark for each feature and 1 mark for further related expansion to max 2 2

• Colour select
• Select all pixels of the same colour

• Add text
• To show the name of the company

• Resize the star shape


• To fit the space available in the box

• Fill an area with colour


• To shade the side of the box

• Select
• ‘Grab’ a number of pixels to perform a task with/to

• Copy
• Replicate a number of pixels

7(b) 1 mark per bullet point 3

• 160 * 160 (= 25600 pixels)


• 25600 * 3 (= 76800 bytes)
• 75 KB (divide by 1024) or 76.8 KB (divide by 1000)

7(c) 1 mark per bullet point to max 2 2

• The logo can be enlarged without becoming pixelated


• because the instructions to create the logo are stored
or
• (Usually) smaller file size
• only coordinates and calculations stored instead of individual pixels

© UCLES 2020 Page 8 of 9 Page 120 of 136


Page 10 Mark Scheme Syllabus Paper
Cambridge International AS/A Level – October/November 2016 9608 12

9 (a) ONE mark for each reason and ONE mark for a further explanation. MAX THREE reasons.

• Reduced data redundancy / data duplication


• Data is stored in (separate) linked tables

• The database (generally) stores data only once / data need only be updated once
• Improved data consistency / integrity / associated data will be automatically
updated / easier to maintain the data / elimination of unproductive maintenance

• Complex queries can be more easily written


• To search / find specific data // specific example related to the Health Club

• Fields can be more easily added to or removed from tables


• Without affecting existing applications (that do not use these fields)

• Program-data dependence is overcome


• Changes to the data (design) do not require changes to programs // changes to programs
do not require changes to data // the data can be accessed by any appropriate program

• Security is improved
• Each application only has access to the fields it needs // different users can be given
different access rights

• Different users can be given different views of the data / data privacy is maintained
• So they do not see confidential information

• Allows concurrent access


• Record locking prevents two users updating the same record at the same time // record
locking assures data consistency
[6]

Page 121 of 136


Page 11 Mark Scheme Syllabus Paper
Cambridge International AS/A Level – October/November 2016 9608 12

(b) ONE mark for each correct relationship as shown.

[2]

(c) An example of a script is shown, but different syntax may be used.

CREATE TABLE CLASS (


ClassID VARCHAR(5),
Description VARCHAR(30),
StartDate DATE,
ClassTime TIME,
NoOfSessions INT,
AdultsOnly BIT,
PRIMARY KEY(ClassID)
);

Mark as follows:
1 mark for CREATE TABLE CLASS and ();
1 mark for PRIMARY KEY(ClassID)
1 mark for both ClassID VARCHAR(5),and Description VARCHAR(30),
1 mark for both StartDate DATE, and ClassTime TIME,
1 mark for NoOfSessions INT,
1 mark for AdultsOnly BIT,
[6]

Page 122 of 136


Page 2 Mark Scheme Syllabus Paper
Cambridge International AS/A Level – October/November 2016 9608 13

1 (a) One mark for each correct line.


Two lines from any box on left means no mark for that description.

Description Database term

Secondary key
Any object, person or thing about
which it is possible to store data

Candidate key

Dataset organised in rows and


columns; the columns form the
structure and the rows form the
content
Entity

Any attribute or combination of


attributes that can qualify as a unique Foreign key
key

Primary key
Attribute(s) in a table that link to a
primary key in another table to form a
relationship

Table

Attribute or combination of attributes


that is used to uniquely identify a
record Tuple

[5]

Page 123 of 136


9608/12 Cambridge International AS/A Level – Mark Scheme October/November
PUBLISHED 2017

Question Answer Marks

7(a)(i) 1 Mark for correct primary key identified in both STAFF and CLIENT 3
STAFF(StaffID, StaffName, Department)
CLIENT(ClientName, Address, Town)

1 Mark for correct primary key identified in VISIT


VISIT(ClientName, VisitDate)

1 Mark for correct primary key identified in INTERVIEW


INTERVIEW(ClientName, VisitDate, StaffID, SpecialistFocus,
InterviewText)

7(a)(ii) 1 Mark for each correct relationship 3

CLIENT VISIT

VISIT INTERVIEW

INTERVIEW STAFF

7(b) 1 Mark for correct answer 1

Add attribute VisitReportText to table VISIT

7(c)(i) 1 Mark for each correct line 3

UPDATE CLIENT
SET ClientName = 'Albright Holdings'
WHERE ClientName = 'ABC Holdings';

7(c)(ii) 1 Mark per bullet, max 2 2

• Referential integrity should be maintained // Referential integrity could be


violated

• Data becomes inconsistent

• There may be records in the VISIT and INTERVIEW tables / other tables with
client name ABC Holdings

• The ClientName in the VISIT and INTERVIEW tables / other tables might not
be automatically updated

• Records in the VISIT and INTERVIEW tables / other tables will become
orphaned

Page 124 of 136


9608/12 Cambridge International AS/A Level – Mark Scheme October/November
PUBLISHED 2017

Question Answer Marks

7(d) 1 Mark for each correct line 3

SELECT StaffID FROM INTERVIEW


WHERE ClientName = 'New Age Toys'
AND VisitDate = '13/10/2016'; (Accept clauses other way round)

7(e) 1 Mark for a correct answer 1


Add a suitable attribute, for example, EuropeTraveller to the STAFF table // Add
a suitable attribute, for example, Country to the CLIENT table

Page 125 of 136


9608/13 Cambridge International AS/A Level – Mark Scheme October/November
PUBLISHED 2017

Question Answer Marks

7(a)(i) PatientID 2
(1)
DoctorID

AppointmentDate, AppointmentTime (1)

7(a)(ii) 2

One PATIENT attends many APPOINTMENTs


One DOCTOR takes many APPOINTMENTs

Special case for 1 mark only (only if no one to many relationships shown)
Many PATIENTs are seen by many DOCTORs
7(b) Two marks from: 2
Either:
• Add an attribute (for example Attended )
• To the appointment table // APPOINTMENT
Or:
• Add an attribute (for example AppointmentsMissed )
• To the patient table // PATIENT

7(c)(i) Available to work at both SITE-A and SITE-B 1

7(c)(ii) APPOINTMENT(Site, AppointmentDate, AppointmentTime, 1


DoctorID, PatientID)

7(d)(i) One mark per line 3

UPDATE DOCTOR
SET DoctorID = '017'
WHERE DoctorID = '117';

7(d)(ii) 1 Mark per bullet, max 2 Max 2

• Referential integrity should be maintained // Referential integrity could be


violated.
• Data becomes inconsistent
• There may be records in the APPOINTMENT table showing doctor ID 117
• The APPOINTMENT table might not be automatically updated
• Records in the APPOINTMENT table will become orphaned

7(e) One mark per line 3

SELECT AppointmentDate, AppointmentTime


FROM APPOINTMENT
WHERE PatientID = '556';

Page 126 of 136


9608/11 Cambridge International AS/A Level – Mark Scheme October/November
PUBLISHED 2019

Question Answer Marks

4(c)(i) 1 mark per bullet point to max 2 2

• Less interference in the signal


• The signal does not degrade as quickly // Needs less signal boosting
• More secure // more difficult to hack
• Greater bandwidth // Faster transmission speeds possible

4(c)(ii) 1 mark per bullet point to max 2 2

• Initial installation cost is higher // Cable / hardware is more expensive to


buy per metre
• Specialists / trained personnel are needed to install / maintain
• Difficult to terminate // The electronics at both ends are more complex
• Fibres can break when bent
• Only transmits data in one direction // Cannot transmit power, only data

4(d)(i) 1 mark per table 3

• Table CUSTOMER with fields FirstName, LastName, DateOfBirth,


CustomerID
• Table ACCOUNT_TYPE with fields AccountID, Name, Bonus
• Table CUSTOMER_ACCOUNT with fields ID, CustomerID, AccountID,
Amount

CUSTOMER (CustomerID, FirstName, LastName, DateOfBirth)

ACCOUNT_TYPE (AccountID, Name, Bonus)

CUSTOMER_ACCOUNT (ID, CustomerID, AccountID, Amount)

4(d)(ii) 1 mark for 1 or 2 correct Primary Keys, 2 marks for 3 correct Primary Keys 2

CUSTOMER: CustomerID
ACCOUNT_TYPE: AccountID
CUSTOMER_ACCOUNT: ID

4(d)(iii) 1 mark for both table name and Foreign Key 1

Table: CUSTOMER_ACCOUNT
Foreign Key: CustomerID / AccountID

4(d)(iv) 1 mark for each correct term 3

Definition Term

All the data about one entity Table / Relation

The data in one row of a table Tuple / Record

A column or field in a table Attribute

© UCLES 2019 Page 7 of 8 Page 127 of 136


9608/12 Cambridge International AS/A Level – Mark Scheme October/November
PUBLISHED 2019

Question Answer Marks

3(d) 1 mark per bullet point to max 2 2

• value1 will still be a string // No conversion to integer


• it will concatenate the digits together rather than add
• by specific example e.g. if 3 is input, 33 will be output rather than 6

Question Answer Marks

4(a)(i) 1 mark per bullet point, max 3 marks from any group to max 4 4

• Multiple tables are linked together


• « which eliminates / reduces data redundancy / duplication
• « and increases data integrity / consistency
• « which reduces compatibility issues
• « so data need only be updated once
• « and associated data will be automatically updated // referential integrity
can be enforced
• « which eliminates unproductive maintenance // which makes it easier to
maintain the data

• Program-data independence means that


• « the structure of data can change and does not affect program
• « the structure of programs can change and does not affect data
• « the data can be accessed by any appropriate program

• Allows concurrent access to data


• « by the use of record locking
• « by restricting over-writing changes

• Complex queries can be more easily written


• ... to search / find specific data // specific example related to the sports club

• Different users can be given different access rights


• « which improves security

• Different users can be given different views of the data


• ... so they do not see confidential information
• « and data privacy is maintained
• « accept a valid example related to the sports club

4(a)(ii) 1 mark for each word in the correct position 4

For a database to be in First Normal Form (1NF) there must be no repeating


groups of attributes.

For a database to be in Second Normal Form (2NF), it must be in 1NF, and


contain no partial key dependencies.

For a database to be in Third Normal Form (3NF), it must be in 2NF, and all
attributes must be fully dependent on the primary key.

© UCLES 2019 Page 5 of 10 Page 128 of 136


9608/13 Cambridge International AS/A Level – Mark Scheme October/November
PUBLISHED 2019

Question Answer Marks

3(a)(ii) 1 mark for 1 or 2 correct Primary Keys, 2 marks for 3 correct Primary Keys 2

CUSTOMER: CustomerID

ROOM: RoomNumber

BOOKING: BookingID

3(a)(iii) 1 mark for both table name and Foreign Key 1

Table: BOOKING
Foreign Key: CustomerID / RoomNumber

3(b) 1 mark per bullet point to max 2 plus 1 mark for suitable example for each 5
DBMS tool

Developer Interface
• To create user friendly features e.g. forms to enter new bookings
• To create outputs e.g. report of bookings on a given date
• To create interactive features e.g. buttons and menus

Query processor
• To create SQL/QBE queries
• To search for data that meets set criteria, e.g. all bookings for next
week
• To perform calculations on extracted data, e.g. number of empty rooms
tomorrow

3c 1 mark for at least two correct rows, 2 marks for all four correct rows 2

Script DDL DML

CREATE TABLE FILMS 9

SELECT FilmID FROM FILMS 9

ALTER TABLE FILMS ADD PRIMARY KEY (FilmID) 9

CREATE DATABASE MYDATA 9

Question Answer Marks

4(a) 1532 1

4(b) 1111 0001 0001 1

4(c) 101 1

4(d) 65 1

4(e) DE 1

© UCLES 2019 Page 6 of 9 Page 129 of 136


9608/11 Cambridge International AS & A Level – Mark Scheme October/November
PUBLISHED 2020

Question Answer Marks

2(a) 1 mark per bullet point to max 4 4


Max 3 if all generic, descriptions not related to benefits to the surgery
Max 3 for a list with no expansions

• Linked tables can be set up


• …the staff in the surgery can set up tables for the pets and their owners
and link them by common attributes

• To reduce / eliminate data redundancy


• …the staff in the surgery usually only needs to enter data once // in the
file system data is probably repeated unnecessarily in different files

• Improved data integrity


• … e.g. if they are searching for an owner’s pets then all results for the
owner should be returned

• Privacy is improved
• … e.g. different views can be given to different users in the surgery.
E.g. the receptionists cannot see the pet’s medical notes

• Referential integrity can be enforced // Unwanted or accidental deletion


of linked data is prevented
• … e.g. the staff in the surgery cannot accidently delete an owner’s
record while there are pets belonging to that owner // Staff cannot enter
an appointment for a pet that does not exist

• Program-data dependence is overcome


• …e.g. the staff in the surgery can add another attribute to the pet table
without affecting the data already stored or the queries already written

• More complex searches and queries can be executed … e.g. the staff in
the surgery can set up a query to only return the names of pets who
have not been seen for over a year

2(b)(i) 1 mark per bullet point to max 1 1

• OwnerFirstName, OwnerLastName and TelephoneNumber are


repeated for owners with more than one pet.

• OwnerFirstName, OwnerLastName and TelephoneNumber are


not dependent on the primary key of the PET table.

© UCLES 2020 Page 4 of 10 Page 130 of 136


9608/11 Cambridge International AS & A Level – Mark Scheme October/November
PUBLISHED 2020

Question Answer Marks

2(b)(ii) 1 mark per bullet point 4

• PET (PetID, PetName, PetBreed, PetDateOfBirth)

• OWNER (OwnerID, OwnerFirstName, OwnerLastName,


TelephoneNumber)

• A linking table between PET and OWNER

• Composite primary key made up of the primary keys of the other two
tables and no extra attributes in the linking table, for example,
PET_OWNER(PetID, OwnerID)

2(c)(i) Structured Query Language // SQL 1

2(c)(ii) 1 mark per bullet point 2

• ALTER TABLE APPOINTMENT

• ADD PRIMARY KEY(AppointmentID); //


ADD UNIQUE (AppointmentID);

2(c)(iii) 1 mark for each correct line 3

• SELECT Time, PetID


(FROM APPOINTMENT)
• WHERE StaffID = "JK1" AND Date = "02/02/2021"
• ORDER BY Time DESC;

2(d)(i) 1 mark for each bullet point to max 2 × 2 4

• Double entry // The data from the form is entered twice (by two different
people)
• and automatically compared

• Visual check // the data is compared (by two different people) after entry
• ... to the paper form manually

2(d)(ii) 1 mark per validation to max 2 2

For example:
• Time can have range check to make sure it is within the opening hours
of 09:00 and 16:50
• Date can have existence check to compare against list of dates they are
open

2(e)(i) 1 mark for each correctly completed term 4

The client-server model has one server that stores all the data for the
surgery. The other computers are clients. When a user requests data, a
request is sent to the server.

© UCLES 2020 Page 5 of 10 Page 131 of 136


9608/11 Cambridge International AS & A Level – Mark Scheme October/November
PUBLISHED 2020

Question Answer Marks

2(e)(ii) 1 mark per correct method to max 2 2

• Usernames and Passwords


• Biometrics // fingerprint recognition // iris scanner
• Two-step verification
• Token authentication // use of dongle // swipe cards

Question Answer Marks

3(a)(i) 1 mark per bullet point to max 2 2

Product:
For example:
• Ensure product is of a high standard
• Ensure product meets requirements
• Ensure the product is delivered within time
• Ensure the product is delivered within budget
• Ensure product development is well-documented
• Ensure product is tested thoroughly // free of bugs

3(a)(ii) 1 mark per bullet point to max 2 2

Colleagues:
For example:
• Need to be fair// do not show any prejudices
• To be supportive of colleagues
• Work together as a team
• Listen to each other’s ideas
• Assist colleagues in professional development
• Fully credit the work of other members of the team
• Make colleagues aware of expected standard ways of working

3(b) 1 mark for naming licence, 1 mark for description to max 2 per licence 4

• Commercial / proprietary...
• ...Software is sold for a fee therefore giving the client the income

• Shareware...
• ...Free for a trial period / limited features, and then users must pay for it

© UCLES 2020 Page 6 of 10 Page 132 of 136


9608/12 Cambridge International AS & A Level – Mark Scheme October/November
PUBLISHED 2020

Question Answer Marks

5(a) 1 mark per bullet point to max 4 4


Max 3 if all generic, descriptions not related to benefits to the teacher.
Max 3 for a list with no expansions

• Linked tables can be set up


• … the teacher can set up tables for her students and their results and link
them by common attributes

• Reduced data redundancy


• … the teacher usually only needs to enter data once

• Improved data integrity


• … e.g. if they are searching for a student’s marks then all results for the
student should be returned

• Program-data dependence is overcome


• … e.g. the teacher can add the results for additional tests without
affecting the data already stored

• Privacy is improved
• … e.g. the teacher can prevent student access to the data (using views
etc.)

• Referential integrity can be enforced // Unwanted or accidental deletion of


linked data is prevented
• … e.g. A teacher cannot enter a mark for a student that does not exist //
the teacher cannot accidently delete a student’s record while there are
test results for that student

• More complex searches and queries can be executed


• … e.g. the teacher can set up a query to only return the test results for
students who achieve below a certain mark

5(b)(i) 1 mark per bullet point to max 2 2

The teacher can ...


• Set up forms for the input of student data
• Add objects to a form to make data input easier, e.g. drop-down boxes
• Design a report for the output of student marks
• Add a menu to select options for different actions

5(b)(ii) 1 mark for each correct item to max 3 3

For example:
• Table / entity names
• Field / attribute names
• Data types
• Validation
• Primary Keys

© UCLES 2020 Page 7 of 11 Page 133 of 136


9608/12 Cambridge International AS & A Level – Mark Scheme October/November
PUBLISHED 2020

Question Answer Marks

5(c)(i) 1 mark for each correct example 3

Database term Field name Table name

StudentID // TestID STUDENT // TEST //


Primary key // StudentID and STUDENT_TEST
TestID

Foreign key StudentID // TestID STUDENT_TEST

Attribute Any field from that table Any table

5(c)(ii) 1 mark for tick in correct box 3


• It is in 3NF

1 mark per bullet point to max 2 for justification:


• (It is in 1NF), there are no repeating groups of attributes // all attributes
are atomic

• (It is in 2NF), there are no partial dependencies

• All fields are fully dependant on the PK // No transitive dependencies

5(c)(iii) 1 mark for each correct answer 5

SELECT StudentID, Mark, MaxMarks / TEST.MaxMarks


FROM STUDENT_TEST, TEST
WHERE / WHERE Test.Topic = "Programming"
AND TEST.TestID = STUDENT_TEST.TestID ;

© UCLES 2020 Page 8 of 11 Page 134 of 136


9608/12 Cambridge International AS & A Level – Mark Scheme October/November
PUBLISHED 2020

Question Answer Marks

5(c)(iv) 1 mark for correct name and 1 mark for corresponding description applied to 6
RESULTS database. Max 2 per rule to max 3 rules

The descriptions are examples only, there are many correct answers

• Length check
• Limit the target grade to 1 character

• Range check
• The mark for each test must be between 0 and MaxMarks

• Existence check
• The test topic must be in a pre-existing list

• Presence check
• A mark must be entered / not null

• Format check
• The data for a class must be one digit followed by one letter, e.g.3A

• Type check
• The maximum marks for a test must be an integer

5(d)(i) 1 mark per bullet point to max 2 2

• Stop unauthorised access // limit access to personal data about students


• Prevent loss of data // avoid students’ test mark being deleted.
• Prevent unauthorised changes to data // prevent students changing
grades

5(d)(ii) 1 mark per bullet point to max 3 for each, max 4 in total 4

Backup
• A copy of the RESULTS database is made
• ... at regular intervals // Sensible frequency of backups, e.g. daily, weekly
etc.
• ... and stored in a different location
• So, in the event of data loss, (most of) the original data may be
recovered.

Disk mirroring
• Data is written to different disks simultaneously
• So, in the event of hardware failure, a second identical copy is
immediately available.

© UCLES 2020 Page 9 of 11 Page 135 of 136

You might also like