0% found this document useful (0 votes)
40 views65 pages

Homework #09 - Questions: Property

Uploaded by

Amira Okasha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views65 pages

Homework #09 - Questions: Property

Uploaded by

Amira Okasha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 65

Homework #09 – Questions

Question 1:

A database table PROPERTY, was set up to show the prices of properties for sale and the features
of each property. Part of the database is shown below.

NumberOfBathrooms
NumberOfBedrooms
PropertyType

BrochureNo

PriceIn$
Garden

Garage
Apartment A01 2 2 No Yes 95000

Apartment A09 2 1 No No 100000

Apartment A16 1 1 No No 150000

Bungalow B17 7 4 Yes Yes 750000

House H10 4 2 Yes No 450000

House H13 3 2 Yes No 399000

House H23 3 1 No Yes 250000

House H46 2 1 Yes Yes 175000

Give the number of fields that are in each record. [1]


…………………………………………………………………………………………………………
State which field you would choose for the primary key [1]
…………………………………………………………………………………………………………
Give a reason for choosing this field. [1]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
State the data type you would choose for each of the following fields. [3]
Garage
…………………………………………………………………………………………………………
Number of Bedrooms
…………………………………………………………………………………………………………
PriceIn$
…………………………………………………………………………………………………………
State the output from this SQL query [3]
SELECT PriceIn$, BrochureNo
FROM PROPERTY
WHERE PropertyType = 'House' AND
NumberOfBedrooms > 2 AND
NumberOfBathrooms > 1
ORDER BY PriceIn$;
Output
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Write a SQL statements to display the brochure number, property type and price of all properties
with a garage below $200,000. [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 2:

A database table MARKS, was set up to record the test results for a class of students. Part of the
database is shown below.

StudentName ClassID Maths English Science History Geography

Diana Abur 0001 92 88 95 89 78

Ravi Gupta 0009 29 34 38 41 44

Chin Hwee 0010 43 47 50 45 52

John Jones 0013 37 67 21 28 35

Rosanna King 0016 21 13 11 27 15

Paul Smith 0017 70 55 65 62 59

Give the number of fields that are in each record [1]


…………………………………………………………………………………………………………
State which field you would choose for the primary key [1]
…………………………………………………………………………………………………………
Give a reason for choosing this field. [1]
…………………………………………………………………………………………………………
State the output from this SQL query [3]
SELECT StudentName
FROM MARKS
WHERE History > 60 OR Geography > 60
ORDER BY StudentName;
Output
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Write a SQL query to select and show the student names only of all students with less than 40
marks in both Maths and English. [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 3:

A picture gallery owner has decided to set up a database to keep information about the pictures
he has for sale. The database table, PICTURE, will contain the following fields:
Title; Artist; Description; CatalogueNumber; Size (area in square centimetres); Price;
Arrived (date picture arrived at gallery); Sold (whether picture is already sold)
State what data type you would choose for each field. [8]
Title
…………………………………………………………………………………………………………
Artist
…………………………………………………………………………………………………………
Description
…………………………………………………………………………………………………………
CatalogueNumber
…………………………………………………………………………………………………………
Size
…………………………………………………………………………………………………………
Price
…………………………………………………………………………………………………………
Arrived
…………………………………………………………………………………………………………
Sold
…………………………………………………………………………………………………………
State which field you would choose for the primary key. [1]
…………………………………………………………………………………………………………
Give a validation check that you can perform on each of these fields. Each validation check
must be different. [4]
CatalogueNumber
…………………………………………………………………………………………………………
Size
…………………………………………………………………………………………………………
Price
…………………………………………………………………………………………………………
Arrived
…………………………………………………………………………………………………………
Write SQL query to select and show the CatalogueNumber, Title
and Price of all unsold pictures by the artist ‘Twister’. [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 4:

A motor boat hire company decides to set up a database to keep information about boats that are
available for hire. The database table, BOAT, will contain the following fields:
BoatName; Model; EnginePower (in hp); NumberOfSeats;
LifeRaft (whether there is a life raft kept on the boat); DayPrice (price for a day’s hire).
Give the data type you would choose for each field. [6]
BoatName
…………………………………………………………………………………………………………
Model
…………………………………………………………………………………………………………
EnginePower
…………………………………………………………………………………………………………
NumberOfSeats
…………………………………………………………………………………………………………
LifeRaft
…………………………………………………………………………………………………………
DayPrice
…………………………………………………………………………………………………………
State a validation check that you can perform on each of these fields. Each validation check must be
different. [4]
BoatName
…………………………………………………………………………………………………………
Model
…………………………………………………………………………………………………………
NumberOfSeats
…………………………………………………………………………………………………………
DayPrice
…………………………………………………………………………………………………………
Write SQL query to select and show the BoatName, Model and
DayPrice of a day’s hire for all boats with 4 seats and an EnginePower of more than 100 hp. [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 5:

A database table STAFFPHONE, was set up to show the telephone extension numbers for
members of staff working in a department store.

Name Department ExtensionNumber

Jane Smith Toys 129

Sue Wong Books 124

David Chow Toys 129

Amy Tang Household 123

Joe Higgs Books 124

Jane Smith Shoes 125

Adel Abur Shoes 125

Peter Patel Toys 129

Explain why none of the fields in the database can be used as a primary key. [2]

…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
State a field that could be added as a primary key. [1]

…………………………………………………………………………………………………………
Give a reason for choosing this field. [1]

…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Write SQL query to provide a list of all members of staff, in alphabetical order, grouped by
department. [3]

…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 6:

A database table SOFASELECT, was set up to show the prices of suites, sofas and chairs for sale
from an online furniture warehouse. Part of the database is shown below.

BrochureNumber

NumberOfPieces
NumberOfSeats
Description

PriceIn$
Material

Colour
Recliner chair RC01 1 1 Leather Cream 600

Chair CH16 1 1 Vinyl Red 250

Chair CH10 1 1 Velvet Red 175

Sofa SF17 2 1 Leather Red 950

Sofa SF19 3 1 Vinyl Black 1000

Suite SU10 4 3 Velvet Green 1500

Recliner sofa RS23 4 1 Leather Cream 1200

Suite SU23 5 3 Leather Brown 950


How many fields are in each record? [1]

…………………………………………………………………………………………………………

State which field you would choose for the primary key.

…………………………………………………………………………………………………………

Give a reason for choosing this field. [1]

…………………………………………………………………………………………………………

State the data type you would choose for each of the following fields.

Number of Seats

…………………………………………………………………………………………………………
PriceIn$

…………………………………………………………………………………………………………

The SQL query below selects all the furniture in cream leather.

SELECT Description, PriceIn$,BrochureNumber


FROM SOFASELECT
WHERE Material = 'Leather' AND Colour ='Cream'
ORDER BY PriceIn$ DESC;

Show the output from the SQL query. [3]

…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Write SQL query to select and show the brochure number, material, colour and price of all the
furniture with 3 or more seats. [3]

…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 7:

A database table THEATRETOURS, was set up to show the tour dates, towns, number of seats
and prices in local currency for a Shakespeare play.

Town TourDate NumberOfSeats PriceLocalCurrency

Windhoek 05/09/2016 65 90

Windhoek 06/09/2016 65 90

Macon 27/08/2016 75 18

Wigan 18/08/2016 120 15

Algiers 01/09/2016 125 1350

Dumfries 20/08/2016 160 12.5

Bordeaux 29/08/2016 170 20

Turin 25/08/2016 200 17

Port Elizabeth 10/09/2016 200 110


Explain why none of the fields in the database can be used as a primary key. [1]

…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………

State a field that could be added as a primary key. [1]

…………………………………………………………………………………………………………
Give a reason for choosing this field. [1]
…………………………………………………………………………………………………………

Write SQL query to provide a list of tour dates and seat prices in alphabetical order of town.
Display Town, TourDate and PriceLocalCurrency in this order. [3]

…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 8:

A database table PLAYPRODUCTION, was set up to show the performance dates, prices and
number of seats available at a theatre specialising in Shakespeare productions.

NumberSeatsCircle
NumberSeatsStalls

PriceCircleSeats$
PriceStallsSeats$
PerformanceDate
Play

As You Like It 01/07/2016 120 90 20 30

As You Like It 02/07/2016 85 45 30 40

As You Like It 09/07/2016 31 4 30 40

Macbeth 14/07/2016 101 56 25 35

Macbeth 15/07/2016 50 34 25 35

Macbeth 16/07/2016 12 5 35 50

Julius Caesar 22/07/2016 67 111 20 20

Julius Caesar 23/07/2016 21 24 15 15

A Comedy of Errors 30/07/2016 45 36 35 45

Give the number of fields that are in each record. [1]


…………………………………………………………………………………………………………
State the data type you would choose for each of the following fields. [3]
Play
…………………………………………………………………………………………………………
NumberSeatsStalls
…………………………………………………………………………………………………………
PriceStallsSeats$
…………………………………………………………………………………………………………
Show what would be output from the SQL query.
SELECT Play, PerformanceDate
FROM PLAYPRODUCTION
WHERE NumberSeatsStalls > 100 OR NumberSeatsCircle > 100
ORDER BY Play;
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Write SQL query to select all the productions with at least six seats left in the circle and show the
Play, Performance Date and Price Circle Seats $ in Performance Date order. [3]

…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 9:

There is a database that stores the following fields:


 EmployeeID, an employee ID which must be two letters followed by 4 numbers, e.g.
TY4587
 Manager, whether the employee is a manager or not
 AnnualHoliday, number of whole days’ annual holiday
 PayGrade, the employee’s pay grade which must be a single letter A–F
Complete the following table to identify:
 The most appropriate data type for each field
 An appropriate validation check for each field. You must use a different validation check for
each variable.

Field Data type Appropriate validation check

EmployeeID

Manager

AnnualHoliday

PayGrade
Question 10:

A database table, DEVICE, has been set up to record the electronic equipment used in a small
business.

DeviceID DeviceTyp User PurchaseDate PurchasePrice$ Portable


e

3 Desktop Alan Swales 14/02/2017 1350 No

4 Laptop Chantel Law 01/02/2016 1460 Yes

5 Tablet Abdula Saud 31/12/2016 1000 Yes

6 Desktop Abdula Saud 14/03/2017 1000 No

7 Laptop Alan Swales 15/03/2016 1700 Yes

8 Tablet Taona Jaji 16/12/2016 470 Yes

SELECT User
FROM DEVICE
WHERE Portable = Yes AND PurchasePrice$ > 1000
ORDER BY User;

Show what would be the output from the SQL query. [2]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Write a SQL query to select all Desktop devices that were either purchased before 31/12/2016 or
cost under $1000. Only show the Device ID and Device Type. [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 11:

A television (TV) store has a database table, TVSTOCK, for its new range of televisions. The table
stores the screen size of each TV, whether it will show 3D, whether the screen is curved or flat, if
the internet is available on the TV, if it has a built-in hard disk drive and the price. Part of the
database table is shown below.

TVID ScreenSize 3D CurvedFlat Internet HDD Price

TV15FTNIN 15 No FT No No 400

TV20FTNIN 20 No FT No No 800

TV37FTINT 37 No FT Yes No 1200

TV42FTINT 42 Yes FT Yes No 1500

TV50CVINT 50 Yes CV Yes No 2500

TV50FTINT 50 Yes FT Yes No 2000

TV50FTNIN 50 Yes FT No No 1750

TV55CVINT 55 Yes CV Yes No 3000

TV55FTINT 55 Yes FT Yes No 3500

TV55FTNIN 55 Yes FT No No 3000

TV60CVINT 60 Yes CV Yes Yes 4500

TV60FTINT 60 Yes FT Yes Yes 4000

TV65CVINT 65 Yes CV Yes Yes 5000

TV80CVINT 80 Yes CV Yes Yes 7000

State the type of the field TVID and give a reason for your choice. [2]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Complete the table with the most appropriate data type for each field. [2]

Field name Data type

ScreenSize

3D

CurvedFlat

Internet

HDD

Price

Write a SQL query to provide a list of all of the curved screen TVs that have a built-in hard disk
drive. Make sure the list only displays the TVID, the price and the screen size in ascending order of
price. [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 12:

A database table, SHEEP, is used to keep a record of the sheep on a farm. Each sheep has a unique
ear tag, EARnnnn; n is a single digit. The farmer keeps a record of the date of birth, the gender and
the current weight of each sheep in kilograms.
Identify the four fields required for the database. Give each field a suitable name and data type.
Provide a sample of data that you could expect to see in the field. [4]
Field 1 name …………………………………………….
Data type …………………………………………….
Data sample …………………………………………….
Field 2 name …………………………………………….
Data type …………………………………………….
Data sample …………………………………………….
Field 3 name …………………………………………….
Data type …………………………………………….
Data sample …………………………………………….
Field 4 name …………………………………………….
Data type …………………………………………….
Data sample …………………………………………….
State the field that you would choose as the primary key. [1]
…………………………………………………………………………………………………………
Write a SQL query to identify the ear tags of all male sheep weighing over 10 kilograms. Only
display the ear tags. [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 13:

A wildlife park has a database table, called LIVESTOCK, to classify and record its animal species.
Part of the database table is shown.

Species Classification Diet Legs

Giraffe Mammal Herbivore 4

Elephant Mammal Herbivore 4

Crocodile Reptile Carnivore 4

Ostrich Bird Omnivor 2


e

Gorilla Mammal Herbivore 2

Bear Mammal Omnivor 4


e

Rhinoceros Mammal Herbivore 4

Hippopotamu Mammal Herbivore 4


s

Flamingo Bird Omnivor 2


e

Lion Mammal Carnivore 4

Turtle Reptile Omnivor 4


e

Penguin Bird Carnivore 2

Suggest another appropriate field that could be added to this database by stating its name and data
type. State its purpose and give an example of the data it could contain.
Field name ……………………………………
Data Type ……………………………………
Purpose ……………………………………
Example of data ……………………………………
Write a SQL query to provide a list of all four legged mammals that are herbivores, sorted
alphabetically by species, with only the species displayed. [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………

Question 14:

A database table, TRAIN, is to be set up for a railway company to keep a record of the engines
available for use. Each engine has a unique number made up of 5 digits, nnnnn. The engines are
classified as freight (F) or passenger (P) together with a power classification that is a whole number
between 0 and 9, for example F8. The railway company keeps a record of the date of the last service
for each engine.
Identify the three fields required for the database. Give each field a suitable name and data type.
Provide a sample of data that you could expect to see in the field. [3]
Field 1 Name ……………………………………
Data type ……………………………………
Data sample ……………………………………
Field 2 Name ……………………………………
Data type ……………………………………
Data sample ……………………………………
Field 3 Name ……………………………………
Data type ……………………………………
Data sample ……………………………………
State the field that you should choose as the primary key [1]
…………………………………………………………………………………………………………
Write the structured query language (SQL) to identify all passenger engines that have not been
serviced in the past 12 months. Only display the engine numbers. [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 15:

A database table, BIKETYRES, is used to keep a record of tyres for sale in a cycle shop.
Tyres are categorised by width and diameter in millimetres, whether they have an inner tube and
the type of terrain for which they are designed.

TyreCode Width Diameter Tube Terrain StockLevel

LLNH 28 700 NO Hard 7

LLNM 28 700 NO Mixed 18

LLNT 28 700 NO Asphalt 19

LLTM 28 700 YES Mixed 12

MLNM 24 700 NO Mixed 22

MLNT 24 700 NO Asphalt 23

MLTH 24 700 YES Hard 5

MLTM 24 700 YES Mixed 14

MSNM 24 650 NO Mixed 4

MSNT 24 650 NO Asphalt 8

SLNM 23 700 NO Mixed 12

SLTH 23 700 YES Hard 10

SLTM 23 700 YES Mixed 22

SLTT 23 700 YES Asphalt 18

SSNT 23 650 NO Asphalt 10

SSTM 23 650 YES Mixed 5

Write SQL query to show the tyre code and stock level in ascending order of stock level for all
24mm asphalt terrain tyres. [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 16:

The table, BEVERAGES, shows the number of calories in 100ml of a range of popular beverages.
It also shows the availability of these drinks in a can, a small bottle and a large bottle.

BevN BevName Calorie Can SmallBottle LargeBottle


o s

Bev01 Cola 40 Yes Yes Yes

Bev02 Lime 45 Yes No Yes

Bev03 Energy Drink 1 52 Yes Yes No

Bev04 Energy Drink 2 43 Yes No No

Bev05 Mango 47 Yes No Yes

Bev06 Lemon Iced Tea 38 Yes No Yes

Bev07 Lemonade 58 Yes Yes Yes

Bev08 Orange Juice 46 Yes Yes No

Bev12 Apple Juice 50 Yes Yes No

Bev15 Chocolate Milk 83 Yes Yes No

Give a reason for choosing BevNo as the primary key for this table. [1]
…………………………………………………………………………………………………………
State the number of records shown in the table BEVERAGES. [1]
…………………………………………………………………………………………………………
List the output that would be given by this SQL query. [2]
SELECT BevNo, BevName
FROM BEVERAGES
WHERE Can = YES AND SmallBottle = YES and LargeBottle = YES
ORDER BY BevName DESC;
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Write SQL query to output a list showing just the names and primary keys
of all the beverages with a calorie count greater than 45. The list should be in alphabetical
order of names. [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Write SQL query to show the total number of calories in all beverages [2]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Write SQL query to show the count of all beverages with a calorie count greater than 40. [2]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 17:

A database table, FLIGHT, is used to keep a record of flights from a small airfield. Planes can
carry passengers, freight or both. Some flights are marked as private and only carry passengers.

FlightNumbe Plane Notes DepartureTime Passengers


r

CN101 Caravan 2 Freight only 08:30 No

CN102 Piper 1 Freight only 09:00 No

CN108 Caravan 2 Freight only 08:00 No

CN110 Lear Private passenger flight 08:00 Yes

FN101 Caravan 1 Private passenger flight 08:00 Yes

FN104 Piper 2 Passengers only 09:20 Yes

FN105 Piper 1 Freight and passengers 10:00 Yes

FN106 Caravan 1 Passengers only 10:30 Yes

State the field that could have a Boolean data type. [1]
…………………………………………………………………………………………………………
A SQL query has been written to display just the flight numbers of all planes leaving
after 10:00 that carry passengers only and private passengers flight.
SELECT Passengers
FROM FLIGHT
WHERE Passengers = Yes AND DepartureTime = #10:00#;

Explain why the SQL query is incorrect, and write a correct SQL query. [5]
Explanation
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Correct SQL query
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 18:

A database table, TRAIN, is used to keep a record of train departures from a station.

TrainNumber Platform Destination DepartureTim Status


e

1A37 1 Newtown 08:00:00 AM On time

2X19 2 Anytown 08:10:00 AM Late

1A29 1 Bigcity 08:15:00 AM On time

1A28 2 Anytown 08:30:00 AM Cancelled

1A67 3 Gardenvillage 08:45:00 AM On time

1A37 1 Newtown 08:50:00 AM On time

1A24 2 Charter Train 09:00:00 AM Late

1A67 3 Gardenvillage 09:15:00 AM On time

Explain why the field Train Number could not be used as a primary key. [1]
…………………………………………………………………………………………………………
A SQL query has been written below to display only the train numbers and platforms of all trains
leaving after 08:30 that are late.
SELECT Platform
FROM TRAIN
WHERE Platform = 'Y' AND DepartureTime < #8:30# OR Status =
'Late';

Explain why the SQL query is incorrect, and write a correct SQL query. [5]
Explanation
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Correct SQL query
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 19:

A car manufacturer makes a range of car models named Pegasus, Apollo and Cupid. It keeps a
database to store the records of its range and the different options for each car model. Within the
table CAR_RANGE, the following data needs to be stored:
1. Car model
2. Body style – saloon, hatchback or estate
3. How many doors it has
4. Whether it uses petrol, diesel or batteries as fuel
5. An identifier for a specific car.
Complete the table to show suitable field names and an example of appropriate data for each
field in the database table CAR_RANGE.

Field name Example of data

State which of your fields would be most appropriate for a primary key and give a reason for
your choice. [2]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Write the SQL query to provide a list of car models using petrol and the
number of doors these cars have, in alphabetical order of car model. Display only the car
models and the number of doors. [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 20:

A database table, SALES, is used to keep a record of items made and sold by a furniture maker.

ItemNumber OrderNumber Notes Amoun Status


t

CH001 1921 Smith - six dining chairs 6 Delivered

TB003 1921 Smith - large table 1 In progress

CH001 1924 Hue- extra chairs 4 In progress

CH003 1925 For stock 2 Cancelled

BN001 1927 Patel - replacement bench 1 Not started

ST002 1931 Sola - small table 1 Delivered

CH003 1927 Patel - eight dining chairs with arms 8 Not started

TB003 1927 Patel - large table 1 Not started

Explain why the field Item number could not be used as a primary key [1]

…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
A SQL query has been written below to display only the order number and item numbers of
any items in progress or not started.
SELECT OrderNumber, Amount
FROM SALES
WHERE Status <> 'Delivered';

Explain why the SQL query is incorrect, and write a correct SQL query. [5]
Explanation
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Correct SQL query

…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 21:

A teacher has decided to use a database table as her mark book for her Computer Science class,
which she has called MARKBOOK. For each student, the following data will be recorded: first
name, last name, their year 10 test score and their year 11 test score. The class has 32 students.
State the number of fields and records required for this database. [2]
Number of Fields ……………………………………
Number of Records …………………………………………..
The data in MARKBOOK is stored under category headings: LastName, FirstName,
Y10TestScore and Y11TestScore.
State, with a reason, whether any of these headings would be suitable as a primary key. [2]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Write the SQL query to only display the first name, last name and year 10
test score of each student who achieved 50 or more in their year 10 test. The output should
be in test score order with the highest marks at the top of the list. [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 22:

A garden centre sells garden tools and stores details of these in a database table named TOOLS.
Code is the primary key in the TOOLS table.

Code Description Price Quantity_Stock Quantity_Ordered


$

GFLG Garden Fork 50 1 50

GHLG Garden Hoe 45 8 0

GSLG Garden Spade 50 11 0

HCSM Hedge Clippers 40 45 0

HFSM Hand Fork 9.99 42 0

HS20 Hose (20 metres) 45 10 0

HS35 Hose (35 metres) 60 2 0

HS50 Hose (50 metres) 75 20 60

HSSM Hand Spade 9.99 40 0

HWS Hand Weeder 9.99 11 0


M

LMBT Lawn Mower (Battery) 249.99 7 0

LMHD Lawn Mower 99.99 5 0

LMPT Lawn Mower (Petrol) 349.99 10 25

SHSM Shears 40 40 0

TRBT Edge Trimmer (Battery) 79.99 15 0

TRPT Edge Trimmer (Petrol) 59.99 20 0

YBLG Yard Brush 24.99 100 0

State the purpose of the primary key in the TOOLS table. [1]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
List the output from the data shown in the table TOOLS that would be given by this SQL query. [2]
SELECT Code, Description, Quantity_Ordered
FROM TOOLS
WHERE Price$ > 40 AND Quantity_Stock > 0 AND Quantity_Ordered > 0
ORDER BY Quantity_Ordered DESC;

…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Write the SQL query to output the tools where the quantity in stock is below 25. Only show the
Code, Description and Quantity_Stock fields in ascending order of Code. [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 23:

A database table, JUICE, is used to keep a record of cartons of fresh fruit juice available for sale.

JuiceCode Fruit1 Fruit2 Size Volum StockLevel


e

LAA10 Apple Apple Large 1000 32

LMM10 Mango Mango Large 1000 5

LMO10 Mango Orange Large 1000 18

LOO10 Orange Orange Large 1000 25

LPP10 Pineapple Pineapple Large 1000 3

MGG05 Guava Guava Medium 500 5

MMM05 Mango Mango Medium 500 12

MOO05 Orange Orange Medium 500 8

MOP05 Orange Pineapple Medium 500 12

SAA02 Apple Apple Small 200 50

SAM02 Apple Mango Small 200 25

SGO02 Guava Orange Small 200 10

SMO02 Mango Orange Small 200 7

SOO02 Orange Orange Small 200 40

SPP02 Pineapple Pineapple Small 200 10

Identify a suitable field to use as the primary key. State a reason for your choice. [2]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Write SQL query to display only the stock level and size of all cartons containing only apple juice.
[3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………

Question 24:

A convenience store which sells general groceries wants to set up a database table called STOCK.
The table will contain fields including a description of the item, the price of the item and the
number in stock for each item. The STOCK table also has a fourth field to be used as a primary
key. Complete the table to suggest a suitable field name for each of the four fields in the table
STOCK. Give the purpose of the data to be stored in each field. [4]

Field name Purpose of field contents

CodeNo Primary key to identify products

Product To describe the product

Price The price of individual item

NumInStock How many are in stock

Write the SQL query to output stock items where the quantity in stock has fallen below 20. Only
show the primary key and description of the items. [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 25:

A database table, BOX, is used to keep a record of boxes made and sold by a craftsman. Boxes are
categorised by:
 SIZE – small, medium or large
 SHAPE – brief description for example ‘star shaped’
 WOOD – maple, beech, walnut or ebony
 PRICE – price in $
 SOLD – whether the box is sold or not.
A database management system uses these data types:
Text Number Real Boolean
Select the most appropriate data type for each field from the four types shown. State the reason why
you chose the data type. [5]
SIZE data type …………………………………………
Reason
…………………………………………………………………………………………………………
SHAPE data type …………………………………………..
Reason
…………………………………………………………………………………………………………
WOOD data type ……………………………………….
Reason
…………………………………………………………………………………………………………
PRICE data type ……………………………………….
Reason
…………………………………………………………………………………………………………
SOLD data type ……………………………
Reason
…………………………………………………………………………………………………………
Write the SQL query to only display the price of small walnut boxes. [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
The SQL query from previous question needs to be changed to show both walnut and beech boxes
and display the wood used. Change the previous SQL query to show the new changes. [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 26:

A database table, CHOCBAR, is used to keep a record of chocolate bars sold. Chocolate bars are
categorised by:
 SIZE – small or large
 FILLING – brief description, for example mint crunch
 PRICE – price in Rupees, for example ₹2.50
 NUMBERSOLD – how many sold
A database management system uses these data types:
Text Integer Currency Boolean
Select the most appropriate data type for these three fields from the four data types shown.
Each data type must be different. State the reason why you chose the data type. [3]
SIZE data type ………………………………………….
Reason
…………………………………………………………………………………………………………
PRICE data type …………………………………………
Reason
…………………………………………………………………………………………………………
NUMBERSOLD data type ……………………………………………
Reason
…………………………………………………………………………………………………………
Write SQL query to display only the price, filling and number sold of small chocolate bars that have
sold fewer than 10 bars. [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 27:

A database table, AIRLINE, stores data used to compare airlines.

Code AirlineNam NumberOfEmployees NumberOfCountrie HeadOffice SharePrice


e s

BJ BlueJet 15000 7 Africa 215.45

FJ FastJet 60000 30 Europe 514.5

JS JetSeven 45000 22 Asia 257.44

K3 Koala3 22000 11 Australia 501.21

MA MurphyAir 35000 8 Europe 152.67

NS NorthState 30000 4 America 108.22

PF PandaFly 50000 35 Asia 317.88

SK SkyKing 32000 27 Europe 506.12

SS SouthState 30000 4 America 126.35

State how many fields and how many records are shown in the AIRLINE table. [2]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Show the output that would be given by this SQL query. [2]
SELECT AirlineName, HeadOffice
FROM AIRLINE
WHERE NumberOfEmployees < 35000 AND SharePrice >500.00;

…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Write SQL query to find every airline with a head office in Asia or Africa, and number of countries
greater than 4. Only show the airline name and number of countries. [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 28:

The table AUDIOPARTS stores the part number, description, cost and quantity in stock of the
items sold by a music shop.

PartNum Description Cost Quantity

A01 Compact Amplifier Case 50 15

A02 Deluxe Amplifier Case 75 1

A03 Amplifier Standard 79.99 48

A04 Amplifier Midrange 149.99 50

A05 Amplifier Megablaster 299.99 48

S01 Tweeter 59.99 10

S02 Midrange Woofer 99.99 0

S03 Subwoofer 139.99 16

S04 Tower Speaker Basic 159.99 25

S05 Tower Speaker Skyscraper 219.99 9

S06 Centre Speaker 149.99 25

S07 Soundbar 89.99 2

S20 Soundbar 129.99 0

S21 Ceiling Surround Speaker 75 15

S22 Ceiling Full Range 100 1


Speaker

S25 Surround Speaker 100 60

State the number of records in the table AUDIOPARTS


…………………………………………………………………………………………………………
Identify the field that is most suitable to be a primary key and give a reason for your choice.
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Write SQL query to show the items where the quantity in stock is fewer than 10. Show all the fields
from the database table in descending order of cost. [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Write SQL query to show the total cost of all parts [2]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Write SQL query to show the count of all parts with a cost less than 100.00. [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 29:

A marine wildlife rescue centre uses a database table, MARINE, to keep records of its creatures.

Creature Class Quantity ReadyForRelease Offspring

Manta Ray Fish 3 Yes No

Short-tailed Albatross Bird 4 Yes No

Emperor Penguin Bird 50 Yes Yes

Bluefin Tuna Fish 2 No No

Manatee Mamma 4 Yes No


l

Hawksbill Turtle Reptile 10 Yes Yes

Hammerhead Shark Fish 3 Yes No

Yellow-eyed Penguin Bird 4 Yes No

Kemp's Ridley Sea Turtle Reptile 1 Yes No

State how many fields and how many records are shown in this table. [2]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Show the output that would be given by this SQL query. [2]
SELECT Creature, ReadyForRelease
FROM MARINE
Where Class = 'Bird';
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Write SQL query to display the creatures, in ascending order of quantity, that have no offspring and
are ready for release. Display only the creature field. [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 30:

A library uses a database table, GENRE, to keep a record of the number of books it has in each
genre.

ID GenreName Total Available Loaned Overdue

ABI Autobiography 500 250 250 20

BIO Biography 650 400 250 0

EDU Education 20200 10000 10200 1250

FAN Fantasy 1575 500 1075 13

GFI General Fiction 35253 23520 11733 0

GNF General Non-Fiction 25200 12020 13180 0

HFI Historical Fiction 6300 3500 2800 0

HNF Historical Non-Fiction 8000 1523 6477 0

HUM Humour 13500 9580 3920 46

MYS Mystery 26000 13269 12731 0

PFI Political Fiction 23561 10523 13038 500

PNF Political Non-Fiction 1823 750 1073 23

REF Reference 374 374 0 0

ROM Romance 18269 16800 1469 0

SAT Satirical 23567 12500 11067 0

SCF Science Fiction 36025 25000 11025 0

SPO Sport 45720 32687 13033 3256

THR Thriller 86000 46859 39141 0

State the reason ID could be used as a primary key in the table GENRE. [1]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
State the number of records in the table GENRE. [1]
…………………………………………………………………………………………………………
Write SQL query to display any genres with overdue books. Only display the ID, GenreName and
Overdue fields in order of the number of books overdue from largest to smallest. [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 31:

A database table, PLANT, is used to keep a record of plants sold by a nursery. The table has these
fields:
 NAME – name of plant
 FLOWER – whether the plant flowers (Yes) or not (No)
 POSITION – shade, partial shade or sun
 SIZE – small, medium or large
 PRICE – price in $
 NUMBERSOLD – how many sold
A SQL query statements has been written to display only the price, name and number sold of small
plants that do not flower.
SELECT NAME, PRICE,NUMBERSOLD
FROM
WHERE POSITION ="Shade";

Identify the errors in the SQL query. [2]


…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Rewrite the corrected SQL query. [2]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 32:

A car hire company uses a database table, TREAD, to store details of the cars. The table has fields
to represent each car’s licence number, mileage, and the tread depth of each of its four tyres.
Suggest suitable names for each of the fields described. [3]
Field name

…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Write SQL query to display cars where all four tyres have a tread depth of less than 2. Display all
the fields, using the field names you created in previous question. The output should be sorted by
licence number. [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 33:

A database table, FLOWER, is used to keep a record of the type of flowers available to make up a
bouquet.

FlowerID Type Colour Style Fragrance

CN001 Carnation Pink Stem Yes

CN002 Carnation Red Stem No

CN103 Carnation White Stem No

CN104 Carnation Yellow Stem Yes

CN105 Carnation Pink Spray Yes

CN106 Carnation Red Spray No

CN107 Carnation White Spray No

CN108 Carnation Yellow Spray Yes

LY101 Lily White Spray Yes

RE101 Rose Pink Stem Yes

RE102 Rose Red Stem Yes

RE103 Rose White Stem No

RE104 Rose Yellow Stem Yes

RE105 Rose Orange Spray Yes

RE106 Rose Peach Spray No


A SQL query has been written to display just the type, style and colour of all flowers that have no
fragrance.
SELECT FlowerID, Fragrance, Style, Colour
FROM FLOWER
WHERE Fragrance = Yes;

Explain why the SQL query is incorrect and write a correct SQL query. [5]
Explanation
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Correct SQL query
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
State the output from this SQL query [2]
SELECT Type, Colour
FROM FLOWER
WHERE Fragrance = No
ORDER BY Type ASC, Colour ASC;

…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 34:

A database table, APPLIANCE, is used to keep a record of kitchen appliances available for sale.
The following data is stored for each appliance:
 CATEGORY – washer, dishwasher, fridge or freezer
 ECONOMYRATING – A, B, C or D
 MANUFACTURER – Baku or ABC
 PRICE – price in $
 CODE – a unique code allocated by the manufacturer e.g. B982
 STOCK – number in stock.
The database management system uses these data types:
Text Real Integer Boolean Character
The ECONOMYRATING field has a data type of character and MANUFACTURER field has a
data type of text.
Identify the most appropriate data type for each field from the four types shown. State the reason
why you chose each data type. [4]
CATEGORY
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
PRICE
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
CODE
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
STOCK
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Write SQL query to display only the category, manufacturer and code of the appliances with an
economy rating of A. [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 35:

A pet supplier uses the database table, PRODUCTSTOCK, to keep records of its products for pets.
The fields are:

Field name Description

ProductID code to identify the product

ProductName name of product

ProductDescription information about the product

Animal type of animal the product is for, e.g. cat, bird, horse

ProductType type of product, e.g. food, toy, medicine

InStock whether the product is in stock or not

Identify the field that could have a Boolean data type. [1]
…………………………………………………………………………………………………………
Identify the field that should be used as the primary key. [1]
…………………………………………………………………………………………………………
Write SQL query to output the products intended for a cat that are in stock. Display only the
primary key and the name of the products. The output should be sorted by the primary key. [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 36:

A database table, COMPUTER, is used to keep a record of computers available for sale.
The following data is stored for each computer:
 CATEGORY – desktop, laptop or tablet
 WEIGHT – weight in kilograms
 MANUFACTURER – ICN, Linoldo, Pear or JoeSing
 PRICE – price in $
 CODE – a unique code allocated by the manufacturer, e.g. P771
 STOCK – quantity in stock.
A database management system uses these data types:
Text Integer Real Boolean
The CATEGORY field and MANUFACTURER field have a data type of text.
Select the most appropriate data type for each field from the four types shown. State the reason why
you chose the data type. [4]
 WEIGHT
…………………………………………………………………………………………………………
 PRICE
…………………………………………………………………………………………………………
 CODE
…………………………………………………………………………………………………………
 STOCK
…………………………………………………………………………………………………………
Write SQL query to display only the category, manufacturer, price and code of the computers with
weight of less than 2.5 kilograms. [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 37:

A computer game shop records its stock levels in a database table called GAMES. The fields used
in the stock table are shown.

Field name Description

GameID primary key

GameName the name of each game

AgeRestriction the minimum age at which a person is allowed to play each game

GamePrice the selling price for each game

NumberStock the quantity of each game currently in stock

OnOrder whether or not each game is on order from the suppliers

DateLastOrdered the date the most recent order for each game was placed

GameDescription a summary of the contents and purpose of each game

State the number of fields that are in the table GAMES. [1]
…………………………………………………………………………………………………………
State one important fact that must be true for a field to be a primary key. [2]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Write SQL query to output all the games that have no stock and that are on order with the supplier.
Display only the GameID, GameName and GamePrice fields in alphabetical order of the name of
the game [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 38:

A database table, NURSE, is used to keep a record of disposable items worn by veterinary nurses.
This is part of the table:

ItemNumbe
Description SingleUse Uses StockLevel ReorderLevel
r

DIG1 Glove (pair) Yes 1 500 800

DIA1 Apron Yes 1 700 800

DIM5 Hair net Yes 1 650 500

DIA2 Apron No 5 25 100

DIS4 Suit No 3 70 50

DIV9 Shoe cover (pair) Yes 1 400 250

Write SQL query to display only the item number and the description of single use items, where the
stock level is below the reorder level. [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Give a reason why the field SingleUse is not required in the table NURSE. [1]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 39:

Data about planets in the solar system is stored in a database table called PLANETS. The fields
used in the table are shown.

Name of field Description

PlanetName the name of the planet

PlanetMass the planet’s mass in kilograms

Larger whether or not the planet has a greater mass than Earth

MaxDistance the maximum distance the planet is from Earth in kilometres

MinDistance the minimum distance the planet is from Earth in kilometres

OnOrder whether or not each game is on order from the suppliers

YearLength the length of time it takes for the planet to orbit the Sun in Earth days

State the name of the field that could contain Boolean data.
…………………………………………………………………………………………………………
Write SQL query to output the planets with a longer year length and greater mass than Earth.
Assume Earth’s year length is 365 days. Display only the name of the planets sorted in alphabetical
order [3]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 40:

A database table, 2018MOV, is used to keep a record of movie details.

CatNo Title Genre1 Genre2 Blu-ray DVD Streaming

18m0
Power Rangers Adventure Fantasy Yes No Yes
1

18m0
Baywatch Comedy Drama Yes No Yes
2

18m0
Table 19 Comedy Drama Yes Yes No
3

18m0
Wonder Woman Action Fantasy Yes No Yes
4

18m0
Justice League Action Fantasy Yes Yes Yes
5

18m0
Twilight Thriller Action Yes Yes No
6

18m0
Ant Man Action Fantasy No Yes No
7

18m0
Venice Beach Action History No Yes No
8

18m1
Fast Five Action Thriller No Yes No
2

18m1
King Kong Adventure Fantasy No Yes No
5

18m1
Transformers: The Last Knight Action Sci-Fi Yes Yes Yes
6

18m1
The Dark Tower Fantasy Sci-Fi Yes Yes No
7

18m1
Beauty and the Beast Fantasy Romance Yes Yes Yes
9

18m2
The Mummy Action Fantasy No No Yes
1

18m2
Star Wars: Episode VIII Sci-Fi Action Yes No Yes
2

18m2
Guardians of the Galaxy Action Sci-Fi Yes Yes Yes
3
18m2
Thor Action Sci-Fi No Yes Yes No
6

18m2
Twilight Fantasy Sci-Fi No No Yes
7

18m3
Beneath Action Fantasy Yes No No
0

18m3
Despicable Me Animation Action Yes Yes No
1

State the number of records in the database table. [1]


…………………………………………………………………………………………………………
Give the name of the field that would be used for the primary key [1]
…………………………………………………………………………………………………………
State the reason for choosing this field for the primary key. [1]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Complete the table to identify the most appropriate data type for each field based on the data shown
in the database table, 2018MOV. [4]

Name of field Description

CatNo

Title

Genre1

Streaming

Complete the structured query language (SQL) to return the category number and title for all
Comedy movies.
SELECT CatNo, Title

……………………………………………………………………………………………………………….. 2018MOV
WHERE Genre1 = ……………………………………………………………………………..;

Question 41:

A shop that sells books has set up a new database table called BookList to store book details.
Part of this table is given.
State the number of records in this part of the database table. [1]
…………………………………………………………………………………………………………
Give the name of the field that would be used for the primary key. [1]
…………………………………………………………………………………………………………
State the reason for choosing this field for the primary key. [1]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………

Complete the table to identify the most appropriate data type for each field based on the data shown
in the table BookList
Write the output from this structured query language (SQL) statement. [2]
SELECT CatNo, Title, Author
FROM BookList
WHERE StockLevel = 0;

…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Complete this SQL statement to display all the titles by the author B Penn [2]

SELECT ……………………………………………

FROM ……………………………………………

WHERE …………………………………………………………………………………..;
Question 42:

A database table, PERFORMANCE, is used to keep a record of the performances at a local theatre.

State the number of fields and records in the table. [2]


Fields
…………………………………………………………………………………………………………
Records
…………………………………………………………………………………………………………
Give two validation checks that could be performed on the ShowNumber field.[2]

…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Show the output that would be given by this structured query language (SQL) statement: [2]
SELECT Date, Title
FROM PERFORMANCE
WHERE NOT SoldOut AND Type = "Jazz";

…………………………………………………………………………………………………………
Question 43:

A database table called TVRange shows the main features and prices of a range of televisions.

Give the name of the field that is most suitable to be the primary key.
State the reason for this choice [2]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
The database uses the data types:
 text
 character
 Boolean
 integer
 real
 date/time.
Complete the table to show the most appropriate data type for each field.
Each data type must be different. [4]

Complete the structured query language (SQL) query to return the television (TV) code,
screen size and price of all Smart TVs in the database table. [4]
SELECT TVCode, ……………………………, ……………………………….

……………………………….TVRange
WHERE SmartTV = ……………………………….;
Question 44:

A music streaming service has a new database table named Songs to store details of songs

available for streaming. The table contains the fields:


 SongNumber – the catalogue number, for example AG123
 Title – the title of the song
 Author – the name of the song writer(s)
 Singer – the name of the singer(s)
 Genre – the type of music, for example rock
 Minutes – the length of the song in minutes, for example 3.75
 Recorded – the date the song was recorded.

Identify the field that will be the most appropriate primary key for this table. [1]
…………………………………………………………………………………………………………
Complete the table to identify the most appropriate data type for the fields in Songs [4]

Explain the purpose of the structured query language (SQL) statements. [3]
SUM (Minutes) FROM Songs WHERE Genre = "rock";

COUNT (Title) FROM Songs WHERE Genre = "rock";

…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 45:

A database table called Site1 stores details of some holiday homes at a holiday park. The

database shows the type of home, number of guests, whether it is privately owned and the weekly
rate to hire it.

State the number of fields and the number of records in this database table. [2]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Describe the purpose of a primary key. [1]
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
The database uses the data types:
 alphanumeric
 character
 Boolean
 integer
 real
 date/time.
Complete the table to show the most appropriate data type for each field. [2]

Give the output that would be produced by the structured query language (SQL) statement: [3]
SELECT Name, NumberGuest, Rate$
FROM Site1
WHERE NumberGuest >= 10;

…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………

You might also like