0% found this document useful (0 votes)
230 views

Dbms Project Final Review PDF

This document provides an overview of a database project for a railway reservation system. It includes an introduction, entity relationship diagram, database design using normalization, and sample SQL queries. The database aims to store information on trains, stations, tickets, passengers and bookings to facilitate functions like ticket booking, cancellation and status checks. Relationships between entities like trains starting/stopping at stations and passengers booking tickets are also modeled.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
230 views

Dbms Project Final Review PDF

This document provides an overview of a database project for a railway reservation system. It includes an introduction, entity relationship diagram, database design using normalization, and sample SQL queries. The database aims to store information on trains, stations, tickets, passengers and bookings to facilitate functions like ticket booking, cancellation and status checks. Relationships between entities like trains starting/stopping at stations and passengers booking tickets are also modeled.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

DATABASE MANAGEMENT SYSTEM - ITE 1003

RAILWAY RESERVATION SYSTEM


PROJECT REVIEW -3

SUBMITTED BY :
18BIT0045 - SAIKUMAR YADAV
18BIT0443 - S.KARTHICK
18BIT0445 - A.K.BALAKRISHNAN

SUBMITTED TO :
DR . SHASHIKIRAN V
ABSTRACT:
The Railway Reservation System faciIitates the passengers to enquire
about the trains available on the basis of source and destination,Booking and
Cancellation of tickets,enquire about the status of the booked ticket, etc. The aim
of case study is to design and develop a database maintaining the records of
different trains, train status, and passengers.
This project contains Introduction to the Railways reservation system .It is the
computerized system of reserving the seats of train seats in advanced. It is mainly
used for long route. On-line reservation has made the process for the reservation of
seats very much easier than ever before.
In our country India, there are number of counters for the reservation of the
seats and one can easily make reservation and get ticket .Then this project contains
entity relationship model diagram based on railway reservation system and
introduction to relation model .There is also design of the database of the
railway reservation system based on relation model. Example of some SQL queries
to retrieves data from rail management database.

INTRODUCTION:
Database is an organized collection of data. The data is typically organized to model
aspect of reality in a way that supports processes requiring information. A DBMS makes it
possible for end users to create. read, update and delete data in a dalabase. The DBMS essentially
serves as an interface between the database and end users or application program ,ensuring that
data is consistently organized and remains easily accessible. The DBMS manages three important
things: the data, the database engine that allows daia to be accessed, locked and modified and
the dalabase schema, which defines the database's logical structure. These three foundational
elements help provide concurrency, security, data integrity and uniform administration
procedures. The DBMS can offer both logical and physical data independence. That means it can
protect users and applications from needing to know where data is stored or having to be
concerned about changes to the physical structure of data.
The main purpose of maintaining database for Railway Reservation System is to reduce the
manual errors involved in the booking and cancelling of tickets and make it convenient for the
customers and providers to maintain the data about their customers and also about the seats
available at them. Due to automation many loopholes that exist in the manual maintenance of
the record can be removed. TI1e speed of obtaining and processing the data will be fast. For
future expansion the proposed system can be web enabled so that clients can make various
enquiries about trains between stations. Due to this. sometimes a lot of problem occur and they
are facing many disputes with customers. To solve the above problem, we design a data base
which include.customer details,availabilty of seats in trains,no of trains and their details.

PROJECT DESCRIPTION:
This is about creating database about railway reservation system. The railway
reservation system facilitates the passengers to enquire about the trains available on the basis
of source and destination. booking and cancellation of tickets, enquire about the status of the
booked ticket, etc.The aim of case study is to design and develop a database maintaining the
records of different trains,train status, and passengers. The record of train include, its number,
name, source, destination, and days on which it is available, whereas record of train status
includes dates for which ticket can be booked, total number of seats available, and number of
seal already booked.
Passengers can book their ticket for the train in which seats are avaiIable . For this, pasenger has
to provide the desired train number and the date for which ticket is to be booked. Before booking
a ticket for a passenger, the validity of train number and booking date is checked. Once the train
number and booking date are validated, it is checked whether the seat is available. lf yes, the
ticket is booked with confirm stand and corresponding ticket ID is generated which is stored along
with other details of the passenger. The ticket once booked can be cancelled at any time. For this.
the passenger ha to provide the ticket ID (the unique key). The ticket ID is searched and the
corresponding record is deleted. With this. d1 first ticket with waiting status also gets confirmed.
List of Assumption Since the reservation system is very large in reality. it is not feasible to develop
the case sn1dy to that extent and prepare documentation at that level. Therefore. a small sample
case study has been created to demonstrate the working of reservation system.

LIST OF ENTITIES AND ATTRIBUTES:


ENTITES ATTRIBUTES
User User id
Password
name
Gender
Age
Email
Aadhar_no
Mobile_no
City
State
Pincode
passenger Passenger id
Name
Gender
Age
Pnr_no
Seat_no
Reservation-status
Train Train_no
Train_name
Arrival_time
Depart_time
Availability_of_seats
Train_no
A_seats
B_seats
W_seats
Station Name
Station No
Train_no
Arrival_time
Hault
Ticket Ticket Id
Train_no
Status
No_of_passenger
RELATIONAL SCHEMA DIAGRAM:
USER:

User_id Name Aadhar_no Gender Age Mobile_no


Email city state pincode password
PASSENGER:

Pnr_no age gender User_id Reservation_status Seat_no P_name


Ticket_id

TRAIN:

Train_no Train_name Arrival_time Depart_time Availability_of_seats Fare


T_date W_seats B_seats A_seats

STATION

Station_No Station_name Hault Arrival_time Train_no

TICKET

Ticket_Id User_id status No_of_passengers Train_no

CANCEL:

User_id Ticket_id Passenger_id

BOOKS:

User_id Ticket_id

STARTS:

Train_no Station_no
REACHES:

Train_no Station_no Reach_time


STOPS_AT:

Train_no Station_no
NORMALIZATION & FINAL OF RELATIONS:
USER:

User_id name Aadhar_no Gender Age Mobile_no


email city state pincode password

PASSENGER:

Pnr_no age gender User_id Reservation_status Seat_no name


Ticket_id
TRAIN:

Train_no Train_name Arrival_time Depart_time Availability_of_seats Fare


T_date W_seats B_seats A_seats

TRAIN STATUS:

train_no w_seat B_seat A_seat

STATION

Station_No Station_name hault Arrival_time Train_no

TICKET:

Ticket_Id User_id status No_of_passengers Train_no

CANCEL:

User_id Ticket_id Passenger_id

BOOKS:

User_id Ticket_id

STARTS:

Train_no Station_no
REACHES:

Train_no Station_no Reach_time


STOPS_AT:

Train_no Station_no
ER DIAGRAM :-
FINAL LIST OF RELATIONSHIPS:
•books -Ternary relation ship between USER,TRAIN,PASSENGER
and TICKET.
•starts-Between TRAIN and STATION reaches -Between TRAIN and
STATION
•cancel -Between USER and TICKET
•stops_at -Between TRAIN and STATION

CREATE &INSERT SQL QUERIES:


CREATE TABLES :
R_USER
create table R_USER(user_id int primary key,name varchar(50),Aadhar_no
varchar(20).gender char,age int.mobile_no varchar(50),email varchar(50),city
varchar(50),state varchar(50),pincode varchar(20)password varchar(50));
TRAIN
create table TRAIN(train_ no int primary key,train_name varchar(50),arrival_time
time ,departure_ time time,availability_of seat char,T_date date);
STATION
create table STATION (Station_no int,Station_name varchar(50),hault int,arrival_
time time,train_ no int primary key , constarint foreign key(train_no) references
TRAIN(train_no));

TRAIN_STATUS
create table TRAIN_STATUS(train_no int primary key,b_seats,a_seats int,w_seats
int fare float);

TICKET :
create table TICKET(Ticket_id int primary key ,user_id int,status char,no_
of_passengers int ,train_no int,constraint foreign key(user_id) references
USER(user_id),constraint foreign key(train_no) references TRAIN(train_no));
PASSENGER :
create table PASSENGER(PNR_NO int primary key,age int,gender char,user_ id
int,reservation_status char,seat_number varchar(5),P_name varchar(50),ticket_id
int,constraint foreign key(user_id) references USER(user_ id), constraint foreign
key(ticket_id) references TICKET(Ticket_id));
STARTS :
create table STARTS( train_no int primary key,station_no int,constraint foreign
key(train_no) references TRAIN(train_no),constraint foreign key(station_no)
references STATION(station_no));
STOPS :
create table STOPS_AT( train_no int,station_no int,constraint foreign key(train_no)
references TRAIN(train_no), constraint foreign key(station_no) references
STATION(no));
REACHES :
create table REACHES (train_no int,station _no int,time time,constraint foreign
key(train_no) references TRAIN(train_no),constraint foreign key(station _no)
references STATION(no));
BOOKS :
create table BOOKS( user_id int ,id int ,constraint foreign key(user_id) references
USER(user_id),constraint foreign key(Ticket_id) references TICKET(Ticket_id));
CANCEL :
create table CANCEL(user_id int,id int,passenger_id int,constraint foreign key(id)
references TICKET(id),constraint foreign key(passenger_id) references
PASSENGER(passenger_id),constraints int foreign key(user_id) references
USER(user_id));
SOME QUERIES :
1. Print user_id and name of all those user who booked ticket for Madurai
Express
SELECT U.USER_ID,NAME
FROM R_USER U,TRAIN T,TICKET TC
WHERE U.USER_ID=TC.USER_ID AND T.TRAIN_NO=TC.TRAIN_NO AND
T.TRAIN_NAME LIKE 'MADURAI EXPRESS';

2. Print detail of passenger travelling under ticket no 4001


SELECT * FROM PASSENGER WHERE TICKET_ID LIKE 4001;

3. Display all those train no’s which reach station no_______

SELECT T.*
FROM TRAIN T,STATION S,REACHES R
WHERE T.TRAIN_NO=R.TRAIN_NO_FK3 AND
R.STATION_NO_FK2=S.STATION_NO AND S.STATION_NAME LIKE 'CHENNAI';
SELECT T.*
FROM TRAIN T,STATION S,REACHES R
WHERE T.TRAIN_NO=R.TRAIN_NO_FK3 AND
R.STATION_NO_FK2=S.STATION_NO AND S.STATION_NAME LIKE 'KOVAI';

4. Display time at which train no __ reaches station no


SELECT R.* ,S.STATION_NAME
FROM REACHES R,STATION S
WHERE R.STATION_NO_FK2=S.STATION_NO;
5. Display details of all those users who canceled ticket for train no
_____
SELECT U.USER_ID,U.NAME,T.TICKET_ID FROM
R_USER U,CANCEL C,TICKET T
WHERE C.USER_ID_FK3=U.USER_ID AND C.TICKET_ID_FK2=T.TICKET_ID;

6. Display the train no with increasing order of the fares


SELECT TS.TRAIN_NO,TS.FARE,T.TRAIN_NAME
FROM TRAIN_STATUS TS,TRAIN T
WHERE T.TRAIN_NO=TS.TRAIN_NO
ORDER BY FARE ASC;

7. Display passenger details for trains

8. Display details of all those passengers whose status is confirmed


for train_no _____
select t.*
from ticket t
where t.status like 'C' and t.train_no=14545;
select t.*
from ticket t
where t.status like 'C' and t.train_no=12525;
select t.*
from ticket t
where t.status like 'C' and t.train_no=17211;

9. Display immediate train from kovai to chennai


SELECT DISTINCT
T.TRAIN_NO,T.TRAIN_NAME,T.T_DATE,T.ARRIVAL_TIME
FROM TRAIN T,STATION S,STARTS ST,STOPS_AT SA
WHERE ST.STATION_NO=(SELECT STATION_NO FROM STATION
WHERE STATION_NAME LIKE 'KOVAI')
AND SA.STATION_NO_FK1=(SELECT STATION_NO FROM STATION
WHERE STATION_NAME LIKE 'CHENNAI');
CREATE PROCEDURE :

1. Display user those who are booked trains under ticket number
create or replace procedure p
(tic number)
is
t number(5);
uid number(4);
stus varchar(2);
np number(2);
cursor c is select train_no,user_id,status,passengers from ticket
where ticket_id=tic;
begin
open c;
loop
fetch c into t,uid,stus,np;
exit when c%notfound;
dbms_output.put_line('train no :' || t);
dbms_output.put_line('user_id :' || uid);
dbms_output.put_line('status :' || stus);
dbms_output.put_line('no of passengers :' || np);
end loop;
close c;
end;

2. DISPLAY TRAIN NUMBERS , WHO BOOKED THAT TRAIN UNDER


PARTICULAR DATE
create or replace procedure p
(td in date)
is
t number(5);
uid number(4);
tid number(4);
cursor c is select tc.train_no,tc.user_id,tc.ticket_id from ticket tc,train t
where t.t_date=td AND t.train_no=tc.train_no;
begin
open c;
loop
fetch c into t,uid,tid;
exit when c%notfound;
dbms_output.put_line('train no :' || t);
dbms_output.put_line('user_id :' || uid);
dbms_output.put_line('ticket id :' || tid);
end loop;
close c;
end;
/
3.DISPLAY PASSENGER WHO BOOKED TRAINS UNDER PARTICULAR
DATE
create or replace procedure p
(td in date)
is
t number(5);
uid number(4);
tid number(4);
pnr number(10);
cursor c is select tc.train_no,tc.user_id,tc.ticket_id,p.pnr from
ticket tc,train t,passenger p where t.t_date=td AND
t.train_no=tc.train_no AND p.user_id=tc.user_id;
begin
open c;
loop
fetch c into t,uid,tid,pnr;
exit when c%notfound;
dbms_output.put_line('train no :' || t);
dbms_output.put_line('user_id :' || uid);
dbms_output.put_line('ticket id :' || tid);
dbms_output.put_line('passenger id :' || pnr);
end loop;
close c;
end;
/

CURSORS :-

DISPLAY, WHICH USERS BOOKING THE TICKETS FOR WHICH


PASSENGERS.

DECLARE
UID NUMBER(4):='&USER_ID';
PID NUMBER(10);
PNAME VARCHAR2(20);
RS VARCHAR2(10);
SNO VARCHAR2(5);
TID NUMBER(4);
CURSOR C1 IS SELECT
PNR,P_NAME,USER_ID,RESERVATION_STATUS,SEAT_NO,TICKET_ID
FROM PASSENGER WHERE USER_ID=UID;
BEGIN
OPEN C1;
LOOP
FETCH C1 INTO PID,PNAME,UID,RS,SNO,TID;
EXIT WHEN C1%NOTFOUND;
DBMS_OUTPUT.PUT_LINE('PNR: ' || PID);
DBMS_OUTPUT.PUT_LINE('NAME: ' || PNAME);
DBMS_OUTPUT.PUT_LINE('USER ID: ' || UID);
DBMS_OUTPUT.PUT_LINE('RESERVATION STATUS: ' || RS);
DBMS_OUTPUT.PUT_LINE('SEAT NO : ' || SNO);
DBMS_OUTPUT.PUT_LINE('TICKET ID : ' || TID);
END LOOP;
CLOSE C1;
END;
/
TRIGGERS :

Trigger is a statement that a system executes automatically when


there is any modification to the database. In a trigger, we first specify
when the trigger is to be executed and then the action to be performed
when the trigger executes.

in our example we have written triggers for passenger table ,


whenever we will modify the table that information stored by
triggers in old table (our example) then we can see that deleted or
updated or inserted information in the old table ..
when passenger table has modified , old table would have
retrieved the modify information by triggers.

Let us see ,

Pl/sql code :-
create or replace trigger passenger_trigger
before delete or insert or update on passenger
for each row
declare
begin
insert into old values(
:old.pnr,
:old.age,
:old.gender,
:old.user_id,
:old.reservation_status,
:old.p_name,
:old.ticket_id);
end;
/
Then trigger will be created.
Here we can see, we will modify some age in our passenger table then
triggers will be fired automatically , then old information stored into old
table
CONCLUSION :-

In our project railway reservation system , we have stored all


information about that the train scheduled at the user booking
tickets and even status of trains , seats etc..

This database is helpful for the application which facilitate


passenger to book the train tickets and check the details of train
and their status from itself , it avoids inconvenience of going to
railway station for each and every query they get .

we had considered the most important requirements only ,many


more features and details can be added to our project in order to
obtain even more users friendly applications.
This applications are already in progress and in future they can be
upgraded and may become part of amazing technology.

USING PROCEDURE AND TRIGGERS AND CURSOR : -


In a case of railway reservation system if a particular person is trying to
take a ticket to a particular destination was kept in waiting list (database)
so his name was displayed as soon as when one passenger cancelled his
ticket in this case the trigger will automatically fired and the waiting list
person data will automatically stored in the database of reserved
passengers ..

You might also like