Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
DBMS VIVA Report
1. Title:- I’m Here -Taxi Reservation
Declaration:
We hold a copy of this assignment that we can produce if the original is lost or damaged.
We hereby certify that no part of this assignment has been copied from any other group’s work
or from any other source. No part of this assignment has been written / produced for our group
by another person except where such collaboration has been authorized by the subject
lecturer/tutor concerned.
Group Members:
Student ID Student Name Signature
BM14047398 D.M Wijayasinghe
BM14413070 D.K.S.M Munasinghe
BM 14404160. S.N.M.N.S Kosgolla
BM 12416172 P.P.L.N.D Jayaratne
BM14418648 T.Nivedha
Note: An examiner or lecturer/tutor has the right not to mark this assignment if the above
declaration has not been signed
Database Management Systems
Assignment
2. The ER diagram
Passenger
P_ID
Fname
Lname
Address
Phone
Make Reservation
ResID
Date
Select
Package
PKID
Name Dis_Rate
e
Vehicle
V_Type
V_number
Seat_c
Air_c
Type
Have Driver
D_ID
F_name
L_name
Age
NIC
dl_no
Phone
Take
Trip
Trid
P_location
D_Location
Distance
1
Wating_time
1
1
1 1
N
1
1
Provided
by
Company
Proid Name
1
1
Trip_fare
N
Address
Phone
WTC
Make
1
Call
C_id
Date
N
Description
Ratting
V_id
Promo_code
Duration
Give
1
1
1
1
1
1
1
N
6. create table trip
(
trid int,
resid int,
vid int,
P_location char(25),
D_location char(25),
distance int,
waiting_time int,
trip_fare money,
constraint pk_id primary key (trid),
constraint rs_id foreign key (resid) references reservation (resid),
constraint v_id foreign key (vid) references vehicle (vid)
)
insert into package
values (1,'gold',0.5,0.20)
insert into vehicle
values ('2','4','AAR6595','1','TUK' ,'Blue','Bajaj','Non A/C','3')
insert into driver
values ('4' ,'Somawardane', 'Siyasinghe', '741921650V', '42', 'B1529770',
'716308207' ,'8'
)
insert into passenger
values (
2,'Sunimal','Rodrigo','329/7,jubili lane,walana,panadura','778751217'
)
insert into company
values ('1','Link Lanka','Galle rd colombo','011 7 533544')
insert into reservation
values (1,1,1,'Car','2016-04-16','Airtel')
insert into trip
values
(
1,1,15,'Kollupitiya Junction','Kaduwela bus Stand','16','5','650'
)
7. 1. Retrieve the Passengers detailswhose first name starting with letter A to N.
select *
from passenger
where fname like '[A-n]%'
2. Retrieve details of the drivers who’s rating more than 5 and age less than 35
select *
from driver
where rating>5 and age<35
3. Retrieve the details of all Tuk type vehicles
select *
from vehicle
where type='TUK'
8. 4. Retrieve the number of vehicles for each type of vehicles
select Type,count(type) as 'number of vehicles'
from vehicle
group by type
5. Retrieve the names of the drivers who have mini type vehicles and their model
select d.fname,d.lname,v.model
from vehicle v,driver d
where d.d_id=v.d_id and v.type='mini'
6. Retrieve the pick location, Drop location and waiting time cost for all trips
select t.P_location,d_location,p.wtc*t.waiting_time as 'waiting time cost'
from reservation r,package p,trip t
where p.pkid=r.pkid and t.resid= r.resid
order by [waiting time cost]
9. 7. Retrieve the all the driver;s names who have trip fare more than driver id 4’s trip
fare
select d.fname,d.lname,v.vid,v.type,sum(t.trip_fare) as 'Total Trip Fare'
from vehicle v,trip t,driver d
where t.vid=v.vid and v.d_id=d.d_id
group by d.fname,d.lname,v.vid,v.type
having sum(t.trip_fare)>
(
select sum(t.trip_fare) as 'Total Trip Fare'
from vehicle v,trip t,driver d
where t.vid=v.vid and v.d_id=d.d_id and d.d_id=4
)
8. Retrieve the total income by each vehicle and got more than 3000
select v.vid,sum(t.trip_fare) as 'Total income'
from trip t,vehicle v
where t.vid=v.vid
group by v.vid
having sum(t.trip_fare)>3000
order by [Total income]
9. Retrieve the names of the drivers with corresponding with their vehicle number
and vehicle type
select d.fname,d.lname,v.vnumber,v.type
from vehicle v,driver d
where v.d_id=d.d_id
10. 10. Retrieve the pick_location , drop_location, waiting cost for all trips by waiting
time cost descending order
select t.P_location,d_location,p.wtc*t.waiting_time as 'waiting time cost'
from reservation r,package p,trip t
where p.pkid=r.pkid and t.resid= r.resid
order by [waiting time cost] desc
11. Retrieve the driver id, name and rating whose rating equal to driver id 4
select d_id ,fname,lname
from driver
where rating =
(
select rating
from driver
where d_id=4
) and d_id<>4
11. 12. Retrieve the vehicle id and average waiting time where greater than average
waiting time of vehicle id=2
select vid,avg(waiting_time )'Average waiting time'
from trip
group by vid
having avg(waiting_time)<
(
select avg(waiting_time)
from trip
where vid=2
)
13. Retrieve the information such as driver full name, vehicle id and type where total
trip fare greater than 1500 and order by according to trip fare
select d.fname,d.lname,v.vid,v.type,sum(t.trip_fare) 'Total Trip Fare'
from vehicle v,trip t,driver d
where t.vid=v.vid and v.d_id=d.d_id
group by d.fname,d.lname,v.vid,v.type
having sum(t.trip_fare)>1500
order by sum(t.trip_fare) desc