Homework #09 - Answers: Property
Homework #09 - Answers: 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.
Title text
Artist text
Description text
CatalogueNumber text/integer
Size real
Price real
Arrived date
Sold Boolean
State which field you would choose for the primary key.
CatalogueNumber
Give a validation check that you can perform on each of these fields. Each validation check
must be different.
CatalogueNumber
Format check/Presence Check/Check Digit/Length check/uniqueness check
Size
Type check/Presence Check/Range Check
Price
Type check/Presence Check/Range Check
Arrived
Type check/Presence Check/Range Check/Format check/Select from calendar length check
Write SQL query to select and show the CatalogueNumber, Title
and Price of all unsold pictures by the artist ‘Twister’.
SELECT CatalogueNumber, Title,Price
FROM PICTURES
WHERE Artist = 'Twister' AND Sold = No;
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.
BoatName text
Model text
EnginePower integer
NumberOfSeats integer
LifeRaft boolean
DayPrice real
State a validation check that you can perform on each of these fields. Each validation check
must be different.
BoatName
Presence Check/Type Check/Character Check
Model
Format check/Type check/Presence Check/Length check/ Use of Drop-down box to select
NumberOfSeats
Type check/Presence Check/Range Check/ Use of Drop-down box to select
DayPrice
Type check/Presence Check/Range Check
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.
SELECT BoatName, Model,DayPrice
FROM BOAT
WHERE NumberOfSeats = 4 AND EnginePower > 100;
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.
e.g. StaffNumber ….
….. Uniquely identifies each member of staff//no duplicates//different for each member
of staff
Write SQL query to provide a list of all members of staff, in alphabetical order, grouped by
department.
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.
BrochureNumber
State the data type you would choose for each of the following fields.
Number of Seats
integer
PriceIn$
real
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.
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
Explain why none of the fields in the database can be used as a primary key.
Performance number …
Give a reason for choosing this field.
Uniquely identifies each performance
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.
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
Play PerformanceDate
As You Like 01/07/2016
It
Julius Caesar 22/07/2016
Macbeth 14/07/2016
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.
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;
User
Alan Swales
Chantel Law
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.
SELECT DeviceID, DeviceType
FROM DEVICE
WHERE DeviceType = 'Desktop' AND (PurchasePrice$ < 1000 OR
PurchaseDate < #31/12/2016#);
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.
It is the primary key/key field with unique data
(Fixed length) text field with alphanumeric data
Complete the table with the most appropriate data type for each field.
ScreenSize Integer
3D Boolean
CurvedFlat Text
Internet Boolean
HDD Boolean
Price Real
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.
SELECT TVID, ScreenSize,Price
FROM TVSTOCK
WHERE CurvedFlat = 'CV' AND HDD = YES
ORDER BY Price;
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.
Field 1 name EarTag
Data type text
Data sample EAR1011
Field 2 name DOB
Data type date
Data sample 04/03/2017
Field 3 name Gender
Data type text
Data sample M
Field 4 name Weight
Data type real
Data sample 5.9
State the field that you would choose as the primary key.
EarTag
Write a SQL query to identify the ear tags of all male sheep weighing over 10 kilograms. Only
display the ear tags.
SELECT EarTag
FROM SHEEP
WHERE Gender ='M' AND Weight > 10;
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 SpeciesID
Data Type Alphanumeric
Purpose Primary key
Example of data SP06583
Field name Number
Data Type Integer
Purpose To record how many of that species there are at the park
Example of data 30
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.
SELECT Species
FROM LIVESTOCK
WHERE Classification = 'Mammal'
AND Diet = 'Herbivore' AND Legs = 4
ORDER BY Species ASC;
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.
Field 1 Name EngineNumber
Data type text/Integer
Data sample 21012
Field 2 Name Class
Data type text
Data sample P6
Field 3 Name ServiceDate
Data type date
Data sample 04/03/2017
State the field that you should choose as the primary key
EngineNumber
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.
SELECT EngineNumber
FROM TRAIN
WHERE Class LIKE 'P*' AND ServiceDate < #10/11/2016#;
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.
SELECT TyreCode, StockLevel
FROM BIKETYRES
WHERE Width = 24 AND Terrain = 'Asphalt'
ORDER BY StockLevel ASC;
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.
Each data value is unique
State the number of records shown in the table BEVERAGES.
10 records
List the output that would be given by this SQL query.
SELECT BevNo, BevName
FROM BEVERAGES
WHERE Can = YES AND SmallBottle = YES and LargeBottle = YES
ORDER BY BevName DESC;
BevNo BevName
Bev07 Lemonade
Bev01 Cola
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.
SELECT BevNo, BevName
FROM BEVERAGES
WHERE Calories > 45
ORDER BY BevName ASC;
Write SQL query to show the total number of calories in all beverages
SELECT SUM (Calories)
FROM BEVERAGES;
Write SQL query to show the count of all beverages with a calorie count greater than 40.
SELECT COUNT (BevName)
FROM BEVERAGES
WHERE Calories > 40;
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.
Explain why the SQL query is incorrect, and write a correct SQL query.
Explanation
Flight number not displayed
Passengers displayed when should not be
Departure time = not >
"Freight and passengers" flight not excluded
Correct SQL query
SELECT FlightNumber
FROM FLIGHT
WHERE Notes = 'Passengers only' OR 'Private passenger flight' AND
DepartureTime > #10:00#;
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.
Number is repeated/not unique
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.
Explanation
Train number not displayed
Departure time before 8:30
Criteria of =Y for Platform not required/incorrect
All late trains will be shown/the condition should use AND not OR
Correct SQL query
SELECT TrainNumber,Platform
FROM TRAIN
WHERE DepartureTime > #8:30# OR Status = 'Late';
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.
CarID ID07
Doors 1 // 2 // 3 // 4 // 5
State which of your fields would be most appropriate for a primary key and give a reason for
your choice.
CarID
Which contains unique values to identify each record
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.
SELECT Model,Doors
FROM CAR_RANGE
WHERE FuelType = 'Petrol'
ORDER BY Model ASC;
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
Explain why the SQL query is incorrect, and write a correct SQL query.
Explanation
Item number not displayed/Amount column not required
Not Like ‘Delivered’ will also show cancelled items
Correct SQL query
SELECT ItemNumber, OrderNumber
FROM SALES
WHERE Status = 'Not Started' OR Status = 'In progress';
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.
Number of Fields 4
Number of Records 32
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.
No field is suitable as a primary key…
…because none of the data would be unique // duplicates could occur
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.
SELECT FirstName, LastName, Y10TestScore
FROM MarkBOOK
WHERE Y10TestScore >=50
ORDER BY Y10TestScore DESC;
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
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.
SELECT Code, Description, Quantity_Stock
FROM TOOLS
WHERE Quantity_Stock < 25
ORDER BY Code ASC;
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.
Juice code
only unique identifier
Write SQL query to display only the stock level and size of all cartons containing only apple juice.
SELECT Size, StockLevel
FROM JUICE
WHERE Fruit1 = 'Apple' AND Fruit2 = 'Apple';
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. [4]
SELECT CodeNo, Product
FROM STOCK
WHERE NumInStock < 20;
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 text
Reason
expressed as a single word
SHAPE data type text
Reason
short phrase required
WOOD data type text
Reason
expressed as a single word
PRICE data type Real
Reason
may be used in calculations
SOLD data type Boolean
Reason
only two choices
Write the SQL query to only display the price of small walnut boxes.
SELECT Price
FROM BOX
WHERE Size = 'Small' AND WOOD = 'Walnut';
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.
SELECT Price, WOOD
FROM BOX
WHERE Size = 'Small' AND (WOOD = 'Walnut' OR WOOD ='Beech');
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 Real 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.
SIZE data type text
Reason
expressed as a single word // Boolean, only two choices
PRICE data type real
Reason
may be used in calculations
NUMBERSOLD data type integer
Reason
integer values/could be used in calculations
Write SQL query to display only the price, filling and number sold of small chocolate bars that have
sold fewer than 10 bars.
SELECT FILLING, PRICE
FROM CHOCBAR
WHERE Size = 'Small' AND NUMBERSOLD < 10;
Question 27:
State how many fields and how many records are shown in the AIRLINE table.
6 fields
9 records
Show the output that would be given by this SQL query.
SELECT AirlineName, HeadOffice
FROM AIRLINE
WHERE NumberOfEmployees < 35000 AND SharePrice >500.00;
AirlineName HeadOffice
Koala3 Australia
SkyKing Europe
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.
SELECT AirlineName, NumberOfCountries
FROM AIRLINE
WHERE NumberOfCountries > 4 AND
(HeadOffice = 'Asia' OR HeadOffice= 'Africa');
Question 28:
The table AUDIOPARTS stores the part number, description, cost and quantity in stock of the
items sold by a music shop.
Write SQL query to show the count of all parts with a cost less than 100.00.
SELECT Count (PartNum) AS NumOfParts
FROM AUDIOPARTS
WHERE Cost < 100.00;
Question 29:
A marine wildlife rescue centre uses a database table, MARINE, to keep records of its creatures.
Creature ReadyForRelease
Short-tailed Yes
Albatross
Emperor Penguin Yes
Yellow-eyed Penguin Yes
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.
SELECT Creature
FROM MARINE
Where Offspring = No AND ReadyForRelease = Yes
ORDER BY Quantity ASC;
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.
The data in the ID column/field is unique/not repeated in each row/record
State the number of records in the table GENRE.
18
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.
SELECT ID, GenreName, Overdue
FROM GENRE
WHERE Overdue > 0
ORDER BY Overdue DESC;
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.
Field name
LicenceNo
Mileage
TyreFLft
TyreFRgt
TyreRLft
TyreRRgt
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.
SELECT *
FROM TREAD
WHERE TyreFLft < 2 AND TyreFRgt < 2
AND TyreRLft < 2 AND TyreRRgt < 2
ORDER BY LicenceNo DESC;
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.
Explanation
Field, FlowerID, not required / should not be displayed
Type field not included and displayed
Fragrance field should not be displayed
Fragrance criteria should not be Yes / should be No
Type Colour
Carnation Red
Carnation Red
Carnation White
Carnation White
Rose Peach
Rose White
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.
CATEGORY – Text characters / words only used
PRICE – Real, may be used in calculation
CODE – Text no calculations required, could be numbers or characters
STOCK – Integer, comparisons and calculations may be required
Write SQL query to display only the category, manufacturer and code of the appliances with an
economy rating of A.
SELECT CATEGORY, MANUFACTURER, CODE
FROM APPLIANCE
WHERE ECONOMYRATING = 'A';
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
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.
WEIGHT – Real, comparisons / calculations may be required
PRICE – Real, calculations may be required
CODE – Text, no calculations required, could be numbers or characters
STOCK – Integer, comparisons / calculations may be required
Write SQL query to display only the category, manufacturer, price and code of the computers with
weight of less than 2.5 kilograms.
SELECT CATEGORY, MANUFACTURER, PRICE, CODE
FROM COMPUTER
WHERE WEIGHT < 2.5
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
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.
SELECT ItemNumber, Description
FROM NURSE
WHERE SingleUse = Yes AND StockLevel < ReorderLevel;
Give a reason why the field SingleUse is not required in the table NURSE.
the field Uses already shows this information // duplication of data // redundant data
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.
Larger
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
SELECT PlanetName
FROM PLANETS
WHERE Larger = Yes AND YearLength > 365
ORDER BY PlanetName ASC;
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 Text
Title Text
Genre1 Text
Streaming Boolean
Complete the structured query language (SQL) to return the category number and title for all
Comedy movies.
SELECT CatNo, Title
FROM 2018MOV
WHERE Genre1 = "Comedy";
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.
Write the output from this structured query language (SQL) statement.
SELECT CatNo, Title, Author
FROM BookList
WHERE StockLevel = 0;
A database table, PERFORMANCE, is used to keep a record of the performances at a local theatre.
length check
type check
presence check
format check
Show the output that would be given by this structured query language (SQL) statement:
SELECT Date, Title
FROM PERFORMANCE
WHERE NOT SoldOut AND Type = "Jazz";
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
TVCode
Each entry in this field is a unique identifier
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.
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.
SELECT TVCode, ScreenSize, Price$
FROM TVRange
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.
SongNumber
Complete the table to identify the most appropriate data type for the fields in Songs
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.
Fields 5
Records 12
Describe the purpose of a primary key.
to uniquely identify a record
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.
Give the output that would be produced by the structured query language (SQL) statement:
SELECT Name, NumberGuest, Rate$
FROM Site1
WHERE NumberGuest >= 10;