A2 SQL
A2 SQL
For example, the product which has ProductId 12345 is a large bench which has a price of £150.
[2]
[4]
The company's technicians keep accurate records of the printers in the building, and the quantity of toner
cartridges in stock, in a flat file database. An extract of the database is shown in Fig. 1.
Fig. 1
Describe two issues, referring to Fig. 1, that might arise from using a flat file database structure.
[4]
PrinterModel: this stores all the data about each model of printer
PrinterInstance: this stores the data about each individual printer in the building
Cartridge: this stores information about the toner cartridges.
Draw an entity-relationship diagram to show the relationships between the three tables.
[4]
3(a) A company sells garden furniture. It has decided to create a relational database. A first, incomplete database
design includes two tables PRODUCT and ORDER.
For example, the product which has ProductId 12345 is a large bench which has a price of £150.
[2]
Describe the purpose of this code and give one situation in which it may be used.
[5]
4(a) Every bank account has an account number and sort code. The sort code identifies the bank branch (location of
the bank) with which the account is held and the account number uniquely identifies the bank account. An extract
from a bank's database table is shown in Fig. 5.1.
State why the table in Fig. 5.1 is not in Third Normal Form.
[1]
[3]
5(a) A programmer needs to design a database to hold details about customers and their orders for an online
company.
[4]
(b) A database contains three tables labelled Customer, Order and Item. Draw an Entity-Relationship Diagram for
these where a Customer can have many Orders and an Order can have many Items.
[3]
A band called RandomBits removes their permission for their songs to be streamed.
The company removes all the songs belonging to RandomBits from their service.
(i) Identify the law with which the company are complying.
[1]
(ii) Write an SQL statement that will remove all songs by RandomBits from the table Song.
[2]
(iii) When the songs have been removed, explain what must happen to the table PlayListEntry if the
database is to retain its referential integrity. (You are not expected to write the SQL to do this).
[1]
InterMovie has a relational database of the films it offers. The database has the field Film Title which stores the
name of a film (e.g. ‘Aliens Attack’).
[2]
(ii) Describe why Film Title would make a suitable secondary key.
[2]
8 A company sells garden furniture. It has decided to create a relational database. A first, incomplete database
design includes two tables PRODUCT and ORDER.
For example, the product which has ProductId 12345 is a large bench which has a price of £150.
State one additional piece of data which should be included in PRODUCT and give one reason why it is needed.
[2]
The forum stores details of its users in the table called Users. An extract of Users is shown below.
1 Zeus 8dfa46a79248037752bba6166fcb34f8 1
2 Hera 74d39d60507eb55e000c6ec5c1265891 0
3 Poseidon b015d770d0208ddcce2c2c719fe29371 0
Describe what is meant by the term ‘primary key’, giving an example from the table above.
[2]
[1]
[2]
[3]
(d)
Sometimes users can have their accounts locked if they behave inappropriately. When this is the case the
locked field is set to 1 rather than 0.
Write an SQL statement that locks the account of the user Hades
[3]
passwordHash and locked have already been extracted from the database before being passed to the
function. It should return the value true if a user should be allowed access to a system and false if they aren’t.
Your function should make use of the pre-written function hash() which takes in a string and returns the hash
of that string.
e.g.
[5]
[2]
(ii) Explain why the programmers have chosen to store the user's IP address.
[2]
State what the value of statement would be after line 03 of the code in Fig. 8 .1 is run.
[1]
(ii) State what the value of hashInDB would be after line 04 of the code in Fig. 8.1 is run.
[1]
The username DenverJ34'; DROP TABLE users; –– is entered into the form.
(i) State what the value of statement would be after line 03 is run.
[1]
[2]
(iii) State the name of a law the user has broken by entering the username
DenverJ34'; DROP TABLE users; --
[1]
[2]
Advantage
Disadvantage
[2]
(c) Users can build up playlists of their songs. Another table is created called Playlist.
Explain why a third table which we shall call PlayListEntry is needed. You should use an ER diagram to
illustrate your answer.
[4]
12(a) The video table consists of the following fields: VideoID, VideoName, Presenter, Topic.
[2]
(ii) Write an SQL query that finds the name and presenter of all videos on the Topic of “The CPU”.
[4]
All pages in the site contain the following tag in the head section.
The exam board wants to use a database to keep track of which videos each student has viewed. The structure
it plans to use is shown below:
(i) Identify one reason why this structure would not be suitable.
[1]
[3]
1 i Unique identifier 2
ProductId identifies a product / OrderId Examiner's Comments
identifies an order
Most students got the “Unique identifier” as
was expected, a few were able to go on
and say what it was used for. Most
candidates were assumed to have not read
the question correctly.
Total 6
Total 8
Total 7
Total 4
5 a Flat file 4
Examiner's Comments
Data Integrity
Linked tables Mostly well answered
Easier to change format
Provides security features
b Correct names 3
1 to many between Customer and
Order
1 to many between Order and Item CAO
Examiner's Comments
Total 7
ii 2
(1
mark per –, max 2)
Total 4
7 i A primary key must have a unique 2 One mark (AO 1.2) for identification of
value for each record (1 – AO1.2) - appropriate reason.
however it is possible for two films to
have the same name (1 – AO2.1). One mark (AO 2.1) for applying knowledge
to given context.
ii A secondary key is indexed allowing 2 One mark (AO 1.2) for identification of
for faster searching (1 – AO1.2) and appropriate reason.
users are likely to want to search by
film (1 – AO2.1). One mark (AO 2.1) for applying knowledge
to given context.
Total 4
NoInStock…
…to check stock levels / allow re- Accept other relevant examples
ordering
Location (in warehouse)… Examiner's Comments
…to find item when needed
A very open ended question that was
designed to test candidates' ability to
hypothesise about what should be in a
database, most candidates achieved a
creditable answer.
Total 2
Examiner’s Comments
Well received and answered by most
candidates.
c SELECT passwordHash, locked (1) 3 Do not award first mark for SELECT *
FROM Users (1)
WHERE username=‘Apollo’ (1) (AO 3.2)
Examiner’s Comments
In most cases, candidates who achieved
marks in c) went on to achieve marks in d)
with few candidates achieving all marks in
either. Many candidates did not use correct
SQL statement structure or syntax e.g.
confusing attribute names with string
literals.
Examiner’s Comments
In most cases, candidates who achieved
marks in c) went on to achieve marks in d)
with few candidates achieving all marks in
either. Many candidates did not use correct
SQL statement structure or syntax e.g.
confusing attribute names with string
literals.
Total 15
ii 0e5a511 1
Total 15
c – would have a 4
many to many relationship
– This is not allowed
– Adding a table between them resolves
this
– Diagram to illustrate this.
(1 per –)
Total 8
Total 10