Homework #09 - Questions: Property
Homework #09 - Questions: Property
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
A database table MARKS, was set up to record the test results for a class of students. Part of the
database is shown below.
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.
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
…………………………………………………………………………………………………………
State which field you would choose for the primary key.
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
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.
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
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.
Windhoek 05/09/2016 65 90
Windhoek 06/09/2016 65 90
Macon 27/08/2016 75 18
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
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
Macbeth 15/07/2016 50 34 25 35
Macbeth 16/07/2016 12 5 35 50
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
Question 9:
EmployeeID
Manager
AnnualHoliday
PayGrade
Question 10:
A database table, DEVICE, has been set up to record the electronic equipment used in a small
business.
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.
TV15FTNIN 15 No FT No No 400
TV20FTNIN 20 No FT No No 800
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]
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.
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.
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.
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.
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.
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.
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.
CH003 1927 Patel - eight dining chairs with arms 8 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.
SHSM Shears 40 40 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.
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]
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:
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.
A marine wildlife rescue centre uses a database table, MARINE, to keep records of its creatures.
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.
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";
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.
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:
Animal type of animal the product is for, e.g. cat, bird, horse
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.
AgeRestriction the minimum age at which a person is allowed to play each game
DateLastOrdered the date the most recent order for each game was placed
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
DIS4 Suit No 3 70 50
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.
Larger whether or not the planet has a greater mass than Earth
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:
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
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.
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
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
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";
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
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;
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………
…………………………………………………………………………………………………………