FA 2 - Databases - SQL Ques Paper

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Name: Subject: Computer Science SL & HL DP Year 1

Topic A- Database Type: Formative Assignment Max Marks: 15 Marks


Management - SQL
Time allocated: 40 minutes Time Taken: Date: April 9, 2024

1. Quick Rent-a-Car is a popular car rental company in Chicago. The company stores information about
the cars, customers, and rental agreements. The diagram below shows a part of the entity-relationship
diagram for the Quick Rent-a-Car database.

(a.i). State the name of one primary key. [1]


CustiD, RentalNum or CarID
(a.ii) State the name on one foreign key. [1]
CustID, or CarID

Some of the information held in the three tables in the Quick Rent-a-Car database is shown below:
(b) State the result from the following query: [1]
SELECT Make
FROM CAR
WHERE Man = "Lexus"
AND Year = 2016;

Ans. EF475

(c) Identify the steps to create a query to find the surname (SName) of the customer who rented the
car from 22 January 2020 (22/01/2020) until 26 January 2020 (26/01/2020). [4]
SELECT SName FROM CUSTOMER
INNER JOIN RENTAL ON CUSTOMER.CustID = RENTAL.CustID
WHERE DateOut = “22/01/2020” AND DateRet = “26/01/2020”;

(d) Identify the steps to create a query to find the contact number (Phone) of the customers who
rented cars made(Make) in year 2015 or 2016. [4]
SELECT Phone FROM CUSTOMER
INNER JOIN RENTAL ON CUSTOMER.CustID = RENTAL.CustID

SELECT CustId FROM RENTAL


INNER JOIN CAR ON CAR.CarID = RENTAL.CarID WHERE Year=2015 OR YEAR=2016;
(e) State a query to display the car serial numbers of cars of the making UX or Pacifica. [2]
SELECT CarSerialNum FROM CAR WHERE MAKE=”UX” OR MAKE=”PACIFICA”;
SELECT CarSerialNum FROM CAR WHERE MAKE IN (”UX”,”PACIFICA”);

(f) State the DDL command to add a new attribute “Fuel_Type” in the table CAR. [2]
ALTER TABLE CAR ADD FUEL_TYPE VARCHAR(10);

You might also like