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

DATABASE Questions

TABLE No. 1

Table reference (2210/21/M/J/20)

Question 1:
a) Which field is most suitable as the Primary key?
b) State the number of fields and records in the above table.
c) Suggest the data type for the all the above mentioned fields.
FIELD NAME DATA TYPE
Code
Description
Price ($)
Quantity_Stock

COMPILED BY ABDUL SAMAD | for self-assessment


Quantity_Ordered
d) State the suitable validation check(s) for the fields mentioned in the above table.
Field Name Validation Check(s)
Code
Description
Price ($)
Quantity_Stock
Quantity_Ordered

e) Write an SQL query to list down the code and description of garden tools that
cost above $40 and is in stocks.
f) List all the tools that are ordered at least once and has a price above $30.
g) Write an SQL query to list down the tools that have $50 price in descending
alphabetical order.
h) List all the code of the tools that starts with character ‘H’ in the ascending order
of price.
i) List all the tools that are not ordered yet and have a price range between $10
and $25.
j) List the prices of tools having code starting initial as ‘H’ and ending initial as ‘M’.
k) List the tools where the quantity in stock is below 25 in ascending order of Code.
l) Write the display of the following queries:
a. SELECT *
FROM Tools
WHERE Price BETWEEN 40 & 60;

b. SELECT Code, Description


FROM Tools
WHERE (Quantity_Ordered = 0) AND (Description LIKE ‘H%’)
ORDER BY Price DESC;

COMPILED BY ABDUL SAMAD | for self-assessment


TABLE No. 2

Table reference (2210/22/M/J/20)

Question 2:
a) Which field is most suitable as the Primary key?
b) State the number of fields and records in the above table.
c) Suggest the data type for the all the above mentioned fields.
FIELD NAME DATA TYPE
Juice code
Fruit 1
Size
Volume (ml)
Stock level

COMPILED BY ABDUL SAMAD | for self-assessment


d) State the suitable validation check(s) for the fields mentioned in the above table.
Field Name Validation Check(s)
Juice code
Fruit 1
Size
Volume (ml)
Stock level

e) Write an SQL query to list down all the fruits and their codes that are available in
large size, at least 200ml and stock level above 5 in reverse alphabetical order.
f) Write an SQL query to list down the juice code of all the medium sized fruits that
have stock level between 5 and 28.
g) Write an SQL query to list down all the fruits with code having ‘MO’ in it, volume
above 200ml in descending order of stock levels.
h) List the code of all the small sized fruits in ascending order of volume.
i) List the stock level and size of all cartons containing only apple juice.
j) Write down the display of the following SQL queries:
a. SELECT *
FROM Juice
WHERE (Fruit 1 LIKE ‘%o’) AND (Fruit 2 LIKE ‘O%’) OR (Size IN ‘Small’)
ORDER BY Stock level;

b. SELECT Juice code,Size


FROM Juice
WHERE (Fruit 1 LIKE ‘A%e’) AND (Fruit 2 LIKE ‘%a%’) OR (Stock level
BETWEEN 5 AND 15)
ORDER BY Stock level;

COMPILED BY ABDUL SAMAD | for self-assessment

You might also like