Dbms Project Final Review PDF
Dbms Project Final Review PDF
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.
TRAIN:
STATION
TICKET
CANCEL:
BOOKS:
User_id Ticket_id
STARTS:
Train_no Station_no
REACHES:
Train_no Station_no
NORMALIZATION & FINAL OF RELATIONS:
USER:
PASSENGER:
TRAIN STATUS:
STATION
TICKET:
CANCEL:
BOOKS:
User_id Ticket_id
STARTS:
Train_no Station_no
REACHES:
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
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';
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';
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;
CURSORS :-
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 :
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 :-