Dbms Transport Final
Dbms Transport Final
(UCS310)
2CO4
Transport Enquiry System
Submitted by:
Bhumika Singh (102103114)
Serra Verma (102103731)
Jiya (102283024)
Jan-May 2023
TABLE OF CONTENT
The Bus Transport Enquiry System is a database management system designed to manage various
aspects of a bus transport company's operations.
The Bus Transport Enquiry System is a software-based solution designed to assist commuters in
accessing information related to bus schedules, routes, fares, and other important details. The
system serves as a one-stop-shop for individuals who rely on public transportation, providing them
with a user-friendly system that they can use to plan their daily commute and ensure timely arrival
at their destination.
With the Bus Transport Enquiry System, users can access information at any time on the location
of their bus and any potential delays or changes to the schedule. The system is designed to be
highly reliable and accurate, using SQL and data analytics to provide the most up-to-date
information possible. The system provides users with information about fares and ticket prices,
enabling them to make informed decisions about their travel expenses. The system enables bus
operators to improve their service delivery by providing users with accurate and up-to-date
information about bus schedules, routes, and fares.
The Bus Transport Enquiry System is a valuable tool for both passengers and bus operators. The
system provides users with real-time information about bus schedules, routes, fares, and other
related information, enabling them to plan their journeys more efficiently. The system also enables
bus operators to improve their service delivery by providing users with accurate and up-to-date
information about bus transport services. Overall, the Bus Transport Enquiry System is a great
addition to the transportation industry, providing users with a convenient and efficient way to
access information about bus transport services.
ER Diagram
Third Normal Form (3NF): Ensure that each non-primary key attribute depends only on the
primary key and not on any other non-primary key attribute.
Table: UserTable
Columns:
- ID (PK)
- Email (UNIQUE, NOT NULL)
- Name
- Password (NOT NULL)
- Usertype (NOT NULL)
Table: NonAdmin
Columns:
- ID (PK, FK to UserTable.ID)
- Gender
- Phone (UNIQUE, NOT NULL)
- Address
Table: Admin
Columns:
- ID (PK, FK to UserTable.ID)
- AgencyName (NOT NULL)
- AgencyPhone (UNIQUE, NOT NULL)
- AgencyOffice
Table: AgencyDetails
Columns:
- AgencyName (PK)
- AgencyAddress
Table: BusInfo
Columns:
- BusRegnNo (PK)
- AgencyName (FK to Admin.AgencyName)
- TotalSeats (DEFAULT 40)
- AC (DEFAULT 0)
- LocationName
- Latitude
- Longitude
Table: BusSchedule
Columns:
- BusRegnNo (FK to BusInfo.BusRegnNo)
- RouteID (CHK > 0)
- StartTime (CHK >= 0 AND < 2400)
- Fare (CHK > 0)
- ReservedSeats (DEFAULT 0)
- TravelTime (CHK > 0)
PK: RouteID, StartTime
Table: TimeForTravel
Columns:
- TravelTime (PK, CHK > 0)
- StartTime (PK, CHK >= 0 AND < 24)
- EndTime (CHK >= 0 AND < 24)
Table: RouteDetails
Columns:
- RouteID (PK, CHK > 0)
- RouteName (NOT NULL)
- Source (NOT NULL)
- Destination (NOT NULL)
- AproxDistance
Table: BusStops
Columns:
- RouteID (FK to RouteDetails.RouteID, CHK > 0)
- IntermediateStops (NOT NULL)
- StopNumber (CHK > 0)
PK: RouteID, StopNumber
Table: DriverDetails
Columns:
- DriverID (PK)
- DriverName (NOT NULL)
- DriverPhone
- Age
- Date_Of_Join
Table: Ticket
Columns:
- TicketPNR (PK)
- BusRegnNo (FK to BusInfo.BusRegnNo)
- BookingDate
- TravelDate
CHK: TravelDate > BookingDate + 2
Table: SeatsBooked
Columns:
- TicketPNR (PK, FK to Ticket.TicketPNR)
- BookedSeats (PK)
Table: SeatInfo
Columns:
- BusRegnNo (PK, FK to BusInfo.BusRegnNo)
- SeatNo (CHK > 40)
- Sleeper (DEFAULT 0)
Table: Passenger
Columns:
- ID (FK to NonAdmin.ID)
- BusRegnNo (FK to BusInfo.BusRegnNo)
- PassengerID (PK, CHK > 0)
- PassengerName
- PassengeGender
- Age (CHK > 5)
Table: Through
Columns:
- RouteID (FK to RouteDetails.RouteID)
- DriverID (FK to DriverDetails.DriverID)
- BusRegnNo (FK to BusInfo.BusRegnNo)
- TicketPNR (FK to Ticket.TicketPNR, CHK > 0)
ER Diagram to Tables
The tables are now in third normal form (3NF), and all data is properly organized to ensure data
integrity and minimize data redundancy.
Here is the relational database schema based on the ER diagram:
UserTable (
ID INT PRIMARY KEY,
Email VARCHAR(255) UNIQUE NOT NULL,
Name VARCHAR(255) NOT NULL,
Password VARCHAR(255) NOT NULL,
Usertype VARCHAR(255) NOT NULL)
NonAdmin (
ID INT PRIMARY KEY,
Gender VARCHAR(255) NOT NULL,
Phone VARCHAR(255) NOT NULL,
Address VARCHAR(255),
FOREIGN KEY (ID) REFERENCES UserTable(ID) ON DELETE CASCADE
)
Admin (
ID INT PRIMARY KEY,
AgencyName VARCHAR(255) NOT NULL,
AgencyPhone VARCHAR(255) NOT NULL,
AgencyOffice VARCHAR(255) NOT NULL,
FOREIGN KEY (ID) REFERENCES UserTable(ID) ON DELETE CASCADE
)
BusInfo (
BusRegnNo VARCHAR(255) PRIMARY KEY,
AgencyName VARCHAR(255) NOT NULL,
TotalSeats INT NOT NULL,
AC BOOLEAN NOT NULL,
LocationName VARCHAR(255),
Latitude DECIMAL(10,8),
Longitude DECIMAL(11,8),
FOREIGN KEY (AgencyName) REFERENCES Admin(AgencyName) ON DELETE
CASCADE
)
RouteDetails (
RouteID INT PRIMARY KEY,
RouteName VARCHAR(255) NOT NULL,
Source VARCHAR(255) NOT NULL,
Destination VARCHAR(255) NOT NULL,
AproxDistance DECIMAL(10,2) NOT NULL
)
BusStops (
RouteID INT NOT NULL,
StopNumber INT NOT NULL,
IntermediateStops VARCHAR(255),
PRIMARY KEY (RouteID, StopNumber),
FOREIGN KEY (RouteID) REFERENCES RouteDetails(RouteID) ON DELETE CASCADE
)
AgencyDetails (
AgencyName VARCHAR(255) PRIMARY KEY,
AgencyAddress VARCHAR(255) NOT NULL
)
BusSchedule (
BusRegnNo VARCHAR(255) NOT NULL,
RouteID INT NOT NULL,
StartTime TIME NOT NULL,
Fare DECIMAL(10,2) NOT NULL,
ReservedSeats INT NOT NULL,
TravelTime TIME NOT NULL,
PRIMARY KEY (BusRegnNo, RouteID, StartTime),
FOREIGN KEY (BusRegnNo) REFERENCES BusInfo(BusRegnNo) ON DELETE CASCADE,
FOREIGN KEY (RouteID) REFERENCES RouteDetails(RouteID) ON DELETE CASCADE
)
TimeForTravel (
TravelTime TIME PRIMARY KEY,
StartTime TIME NOT NULL,
EndTime TIME NOT NULL
)
DriverDetails (
DriverID INT PRIMARY KEY,
DriverName VARCHAR(255) NOT NULL,
DriverPhone VARCHAR(255) NOT NULL,
Age INT NOT NULL,
Date_Of_Join DATE NOT NULL
)
Ticket (
BusRegnNo VARCHAR(255) NOT NULL,
TicketPNR VARCHAR(255) PRIMARY KEY,
BookingDate DATE NOT NULL,
TravelDate DATE NOT NULL,
FOREIGN KEY (BusRegnNo) REFERENCES BusInfo(BusRegnNo) ON DELETE CASCADE
)
SeatsBooked (
TicketPNR VARCHAR(255) NOT NULL,
BookedSeats VARCHAR(255) NOT NULL,
PRIMARY KEY (TicketPNR),
FOREIGN KEY (TicketPNR) REFERENCES Ticket(TicketPNR) ON DELETE CASCADE)
SeatInfo (
BusRegnNo VARCHAR(255) NOT NULL,
SeatNo INT NOT NULL,
Sleeper BOOLEAN NOT NULL,
PRIMARY KEY (BusRegnNo, SeatNo),
FOREIGN KEY (BusRegnNo) REFERENCES BusInfo(BusRegnNo) ON DELETE CASCADE
)
SQL (Code & Outputs)
SELECT *
FROM UserTable
LEFT JOIN NonAdmin ON UserTable.ID = NonAdmin.ID
LEFT JOIN Admin ON UserTable.ID = Admin.ID
LEFT JOIN BusInfo ON Admin.AgencyName = BusInfo.AgencyName
LEFT JOIN AgencyDetails ON Admin.AgencyName = AgencyDetails.AgencyName
LEFT JOIN BusSchedule ON BusInfo.BusRegnNo = BusSchedule.BusRegnNo
LEFT JOIN TimeForTravel ON BusSchedule.TravelTime = TimeForTravel.TravelTime AND
BusSchedule.StartTime = TimeForTravel.StartTime
LEFT JOIN RouteDetails ON BusSchedule.RouteID = RouteDetails.RouteID
LEFT JOIN BusStops ON BusSchedule.RouteID = BusStops.RouteID
LEFT JOIN Ticket ON BusSchedule.BusRegnNo= Ticket.BusRegnNo
LEFT JOIN SeatsBooked ON Ticket.TicketPNR = SeatsBooked.TicketPNR
LEFT JOIN SeatInfo ON BusSchedule.BusRegnNo = SeatInfo.BusRegnNo
LEFT JOIN Passenger ON Passenger.BusRegnNo = BusSchedule.BusRegnNo
LEFT JOIN Through ON BusSchedule.RouteID = Through.RouteID AND
BusSchedule.BusRegnNo = Through.BusRegnNo
OUTPUT
Output in Excel .csv File
Conclusion
In conclusion, the Bus Transport Enquiry System is an efficient and effective way to manage and
monitor the bus transportation system. It provides information to the passengers about the arrival
and departure of buses, the estimated time of arrival at their destination, and other relevant
information. It also allows bus companies to manage their fleet efficiently, keep track of their
drivers' performance, and optimize their routes to reduce travel time and fuel consumption. The
system also facilitates communication between passengers, drivers, and bus companies, leading to
better customer satisfaction.
The Bus Transport Enquiry System is a modern solution to the challenges facing the bus
transportation industry and its implementation can revolutionize the way people travel andimprove
the quality of life for millions of passengers.
References
[1] https://livesql.oracle.com/
[2] https://www.oracletutorial.com/oracle-basics/
[3] https://www.tutorialspoint.com/plsql/plsql_triggers.htm
[4] https://www.tutorialspoint.com/plsql/plsql_procedures.htm
[5] https://www.tutorialspoint.com/plsql/plsql_cursors.htm