Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Database (Questions)

1.

a) Give a reason for choosing BevNo as the primary key for this table. [1]
__________________________________________________________________________________

b) State the number of records shown in the table BEVERAGES. [1]


__________________________________________________________________________________

c) List the output that would be given by this SQL statement SELECT BevNo, BevName FROM
BEVERAGES
WHERE Can = "Yes" , Small Bottle = "Yes" , Large Bottle = "Yes" ORDER BY BevName DESC ; [3]
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________

d) Write an SQL statement 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. [4]
(Q5/21/M/J/19)
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________

1|Page
2.

a) State the purpose of the primary key in the TOOLS table. [1] (Q6/21/M/J/20)
__________________________________________________________________________________

b) List the output from the data shown in the table TOOLS that would be given by this SQL statement.
SELECT Code, Description, Quantity_Ordered FROM TOOLS WHERE Price > "40" AND Quantity_Stock
> "0" AND Quantity_Ordered > "0" ORDER BY Quantity_Ordered DESC; [3]
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________

c) Write the SQL statement 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]
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________

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

a) Identify a suitable field to use as the primary key. State a reason for your choice. [2]
(Q6/22/M/J/20)
__________________________________________________________________________________
__________________________________________________________________________________

b) Write an SQL statement to display only the stock level and size of all cartons containing only apple
juice. [4]
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________

4. The table AUDIOPARTS stores the part number, description, cost and quantity in stock of the items
sold by a music shop. (Q7/22/O/N/20)

a) State the number of records in the table AUDIOPARTS. [1]


__________________________________________________________________________________

3|Page
b) Identify the field that is most suitable to be a primary key and give a reason for your choice. [2]
__________________________________________________________________________________
__________________________________________________________________________________

c) Write an SQL statement 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.
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________

5. (Q5/23/O/N/20)

a) State how many fields and how many records are shown in this table. [2]
__________________________________________________________________________________
__________________________________________________________________________________

b) Show the output that would be given by this SQL statement. [2]

__________________________________________________________________________________
__________________________________________________________________________________

4|Page
6. Q. 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 (True) or not (False)
• POSITION – shade, partial shade or sun
• SIZE – small, medium or large
• PRICE – price in
• NUMBERSOLD – how many sold
A Structured Query Language (SQL) statement has been written to display only the price, name and
number sold of small plants that do not flower.
SELECT Price, Name, NumberSold
WHERE position = "shade" ;
Identify the errors in the SQL statement.
..................................................................................................................………….....................................
..................................................................................................................................................................
..................................................................................................................................................................
.................... ...................................................................................

Rewrite the corrected Structured Query Language (SQL) statement. [5] (Based on Q6/22/M/J/21)
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________

5|Page
7. A library uses a database table, GENRE, to keep record of the number of books it has in eachgenre.

a) State the reason ID could be used as a primary key in the table GENRE. [1]
__________________________________________________________________________________

b) State the number of records in the table GENRE. [1]


__________________________________________________________________________________

c) Write an Structured Query Language (SQL) 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. [4] (Q6/21/M/J/21)
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________

8. Q. A database table, MUSEUM, is used to keep a record of items in the museum. The table has
these fields:
• ItemCode – code for each type of item, for example ART0005
• Description – brief description of each item, for example gold coin
• InStore – whether the item is in store or not, for example Y
• Century – century when item made, for example 18
• Country – country of origin, for example China.

a) Identify which field you would choose for the primary key. State a reason for your choice. [2]
(Q5a/23/O/N/22)
__________________________________________________________________________________
__________________________________________________________________________________

6|Page
b) Write an Structured Language Query (SQL) to display only the description and the country of
origin for those items not in store [4]
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________

9. A school uses a database table, ASSESS, to keep a record of the internal assessments and the
number of candidates for each of the subjects in it's curriculum.

This database only allows the data types: • Text


• Integer
• Boolean
• Currency

a) i. State the most appropriate data type for the fields SubjectCode and Exams.[1]
__________________________________________________________________________________
ii. State one reason why the candidate field could not be the Boolean Data type. [1]
__________________________________________________________________________________
(7a/22/O/N/22)

b) Show the output given by the Structured Language Query (SQL); SELECT SubjectName, Candidates
FROM ASSESS
WHERE Practicals < "1"
ORDER BY SubjectName ; [3]
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________

c) Write the Structured Language Query (SQL) to output the subjects with fewer than 150
candidates. Display only the SubjectCode, SubjectName and Candidates fields in order of the number
of candidates from largest to smallest. [3]
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________

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

a) State the number of fields that are in the table GAMES. [1]
__________________________________________________________________________________

b) State one important fact that must be true for a field to be a primary key. [1]
__________________________________________________________________________________
(Q6/21/M/J/22)

c) Write a Structured Language Query (SQL) 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]
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________

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

a) Write an Structured Language Query (SQL)to display only the item number and the description of
single use items where the stock level is below the reorder level. [4]
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________

b) Give a reason why the field SingleUse is not required in the table NURSE. [1] (Q6b/22/M/J/22)
__________________________________________________________________________________

8|Page
__________________________________________________________________________________
__________________________________________________________________________________

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

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


__________________________________________________________________________________

b) (i) Give the name of the field that would be used for the primary key. [1]
__________________________________________________________________________________
(ii) State the reason for choosing this field for the primary key. [1]
__________________________________________________________________________________

c) Complete the table to identify the most appropriate data type for each field based on the data
shown in the database table, 2018MOV. [2]
__________________________________________________________________________________
__________________________________________________________________________________

9|Page
13. d) Complete the structured query language (SQL) to return the category number and title for all
Comedy movies.

SELECT CatNo, Title


.................................................. 2018MOV
WHERE Genre1 = ..................................................; [2]

10 | P a g e

You might also like