You are on page 1of 2

‫بسم اهلل الرمحن الرحيم‬

Assignment-I

Consider the database of a car rental company that contains three tables drivers, cars and
reservation tables.
Drivers: Reservation: Cars:
Dno Dname age Dno Cno Day Cno Cmake Color
22 Dustin 45 22 101 10/10 101 BMW Blue
29 Brutus 33 22 102 10/10 102 VW Red
31 Lubber 55 22 103 10/8 103 OPEL Green
32 Andy 25 22 104 10/7 104 FIAT Red
58 Rusty 35 31 102 11/10
64 Horatio 35 31 103 11/6
71 Zorba 16 31 104 11/12
74 Horatio 35 64 101 9/5
85 Art 25 64 102 9/8
95 Bob 63 74 103 9/8
23 Alice 15 23 104 9/11

1. Write DDL statements to create the tables


Drivers(Dno, Dname, age)
Reservation(Dno, Cno, Day)
Cars(Cno, Cmake, Color)
Where:
 no field could be empty except the age of the Driver.
 The company does not own more than one car from one maker
 the colors of the cars should not be other than the following group
(blue, white, red , green)

2. Write Queries for the following:


a. Insert the sample data shown above into the tables

3. Write Queries for the following:


a. Find the names of drivers who have reserved car no 103.
b. Find the names of Drivers who have reserved red or Green
cars.( use IN, UNION, =SOME/=ALL, and JION each in
separate query) ‫ اجيابات باستخدام العمليات املوضحة فيما بني‬4 ‫هلذه اجلزئية جيب ان‬
‫االقواس‬
c. Find the driver Dno of drivers with age over 20 who have not
reserved a read car.
d. Find the names of drivers who have reserved all cars.
e. List the name of the drivers along with the day they rent cars in
descending order
f. List the name of the drivers whom rent more than 3 times along
with the number of the times.
g. Change the age of Alice to 18 years old
h. Delete the information of the drivers younger than 20 years old

You might also like