Professional Documents
Culture Documents
1. Consider the following Database of Bus transport system . Many buses run
on one route.
Drivers are allotted to the buses shiftwise.
Following are the tables:
BUS (BUS_NO INT , CAPACITY INT , DEPOT_NAME VARCHAR(20))
ROUTE (ROUTE_NO INT, SOURCE CHAR(20), DESTINATION CHAR(20),
NO_OF_STATIONS INT)
DRIVER (DRIVER_NO INT , DRIVER_NAME CHAR(20), LICENSE_NO INT,
ADDRESSCHAR(20), D_AGE INT , SALARY FLOAT)
The relationships are as follows:
BUS_ROUTE : M-1
BUS_DRIVER (bno,dno,dated,shift) M-M with descriptive attributes Date of duty allotted and
Shift — it can be
(Morning) or ( Evening ).
Constraints: 1. License_no is unique. 2. Bus capacity is not null.
Creating tables:
fybc=# create table route (rno int primary key, source varchar(20), destination
varchar(20), no_of_stations int);
CREATE TABLE
fybc=# create table bus (bno int primary key, capacity int not null, depot_name varchar(20),
rno int references route(rno) on delete cascade on update set null);
CREATE TABLE
fybc=# create table driver (dno int primary key, dname varchar(20), license_no int unique,
address varchar(20), d_age int, salary float);
CREATE TABLE
fybc=# create table bus_driver (bno int references bus(bno) on delete cascade on update set null,
dno int references driver(dno) on delete cascade on update set null, date_of_duty date, shift
varchar(20) check(shift in ('morning','evening')));
CREATE TABLE
Inserting Values:
(3 rows)
trim2=# select * from bus;
bno | capacity | depot_name | rno
+ + +
101 | 50 | mumbai central | 64120
102 | 30 | pune central | 64001
103 | 40 | ernakulam | 64101 104 | 40 |
deccan | 64001
105 | 50 | edappally | 64101 (5 rows)
trim2=# select * from driver;
dno | dname | license_no | address | d_age | salary
+ + + + +
121 | Ram | 124201 | pune | 42 | 32000
122 | Sham | 134209 | mumbai | 40 | 25000
123 | Laxman | 142301 | kochi | 45 | 45000
(3 rows)
Only two pages are converted. Please Sign Up to convert all pages.
https://www.freepdfconvert.com/membership