It is grcat pleasure for mc to cxpmss my gratitude to our honorable President
SrJ. Koneru Satvanarayana, for giving the opportui\ily and platform with
fâc iliti Jñs i n a cc ompIish1^8 t*e Project based laborolory report.
odministratiou fowards our acadvmic growt!t.
I cxprcss sinccr¢ gr8titudc to our Coordinator Dr. A- Satya Kal¿an For
his
acadamic Semester.
I record it as my privilcge to docply tI+ank our pionccr Dr. V. Srikanth,
HOD CSE D«pt
idcas inlo rmalify.
I express my sincere lhanks to our project supervisor [Link] Rao
Finally, it is pleased to acknowledge the indebtedness lo all those whn
devoted themselves dimtly or indirectly to make ihis projcct rcpon success
PROJECT ASSOCJATES
Student ID
Shashank Rrdd 150030407
T. Jai Sai Cliand 1 5003ß936
ACKNOWLEDGE\4Ei ITS .
£'ROJECT DESC’RIPTION.
ER Diogrem {CaccgI‹ia1 Model)
SQL Queries laicd to Rcpon Gcncietion
The Railway Rescrvalion Sys‹ racilitatcs 1hc passengers to enquire about
fhc frains available on tho basis of sourc¢ and dcstinafioa, Booking end
Cancellation of tickets, enquire about th¢ slatus of the booLc'd tickot, etc. be aim
of case study is to design and develop a database maintaining lhe records of'
diff‘erent trains, train starus, and passengers.
This project contains Inlroduclior la the R ai Sways reservation
ft is lhe computerized system of reserving lhe seats of fi'ain seals in
advanced. It is mainly used for long route. On-line reservation has made the
process for the rz'servation of scats very much easier than ever before
In our counlry fnd ia, there are number oÏ' counters for the reservation of
lÏie seats and one can easily maLe reservetions and get ticLets. Then lhis project
conlains cnlity zetalionship model 4iagiam based on railway reservation systcm
Tttcrc is also dcsign of the dat8bcsc
of fhc railway res¢rvstion syefcm bescd on mlation mud¢l. Exampl¢ ofhome SÇL
qucries lo mlrieves óatc from mil maaagement daiabasc.
Database is sn organized collection of d‹tta. The detg is typically orgenizcd
\u modol aspects of reality in a way that supports proc<ss¢s requiring information.
A DBMS makes it possible for end users to create, ruad, update and delete data in a
database. The DBMS essentially serves as Bn interface between IJie database and
end users or application programs, ensuring ihal 4aia is coasist¢ntTy organized and
remains c8sily acccssiblc Tkc DBMS manages fhrec important things: thc date. the
database cnginc that altows data to bc accessed. locked and modified and the
database schema, wI\icfi defines lhe database’s 1ogical structure. Thae three
foundations I elemenls help provide concuzzency, security, dala integrily and
uniFonn administration pn›ccdurcs. The DBMS can offer both logical and physical
data indcpcndcnc¢ That mcans it csn protect users and applications from n¢¢ding
fa know whmro da\a is stored or taking \o be concerned about changes to the
physical slructuz¢ of data.
The main purpose of' maintaining database for Railway Reservation Syste T
is to reduce the manual errors involved in the booking and cancelling of wickets and
make it convenient for fhc customers sn4 provi4crr to maintain thc dala about tltcir
cu8tomcrs and also about \ftc seals available at \i\[Link] \o automation many
loopholes that esist in the manual mainlmance oftI\e reconh can be removed. The
speed of obtaining and processing the data will be fast. For f\ifure expansion the
proposed system can be web enabled so ihat clicnu can make vBzious enquiries
Due to this. sometimes a Koi of problems occur and
fhcy are facing m›uty Jispu\cs witft customers. To solve fhc above problem, we
design a data base which includes customer details, availability of seats in trains,
no of frnins Bnd II\eir details
This p›cject i8 about cr¢ating \t\e daIaba&¢ aboul Railway Reservatio›t System.
The railway rcscrvalion system £ecilitetcs the pnss‹x gcrs to enquiry about
fhc trains svailablc on th¢ basis of source and dcetination, backing and ciinccl1ation
of tickets, enquizu about the status of the boo1ed ticket, etc. The aim of case stucly
is to design and develop a database maintaining the records of diJTerent tiains, bain
starus, and passengers. The record oF uain includes its number, nome, source,
dcstirrBtion, auld days on which it is available, whereas record oF train status
includes datas for which ‹ickcu can b¢ bookc‹L total number of seals ‹tvailsbTc, ard
number of scats already book¢d
Passcnj ers can book their úckets for the train in which scats are avaiJabtc.
For tltis, yzsscngcr has 1o yrovidc tfte dcsircd train numbcr and the da‹c for whictt
ficket is to be book¢d Befor¢ booking a tickct for a passcng¢r, fhc volidify oftmin
number and booking óate is chcckcd Once ttte Itain numbcr and booki‹tg date am
validated, it is checLed wI\ether the seat is avai1able. If' ygs, the ticket is booked
with confirm status and coriesponding ticket ID is generated which is slored along
with oth¢r detalls of rh¢ passcngcr. Th¢ tickct onc¢ bookcd can b¢ canccllcd et any
fimc. For this. th¢ passcngcr h8s to providc the tickct ID (the unique kcy). The
ficket fD is scorchod and \he corrssponding record is det¢ted. With fhis, fhe fi›st
tic1et witlt waitiI\g stalus a1so gels confirmcd.
List of Assumption Since lhe reservation system is very large in reality, it is
not feasible to develop the case study to that cxlent and prepare documentation a1
thai ltvcl, Thcreforc, a small sample case study be been curated to dcmonstraic
the working of the reservation system. To implewuni this sample case study, some
assumptions have been made, which are as follows:
1. The number of trains hns been restricted to 5.
2. Who booking is open only for next seven days from the current dale.
3. Only ‹wo categories nd tickets can be booked, namely, AC anlt General.
4. The total number ofticLets that can be booked in each category (AC nnd
Geneml) is 10.
5. The touil number of tickets lhat can be given ldc slatus of mailing is 2.
6, The in- between stoppage suitions and their book ings arc not considered,
List uf tniins has to be maintainr'd. Dmailcd Passenger information iz to b¢
read from the passenger. On the basis of” the values provided by the passenger,
corresponding record is retrieved from ihe Train Statns. JI the desired category is
AC, then total number of AC seats and number or booked AC sca‹s are compared
in order to finJ whether fickct can be buukc4 or not. Similarly, it cen be checked
for th¢ g¢n¢ral coi¢gory. TF fick¢t ccn bo book¢d. then passenger details am md
and slorcd in the f'assenger table. In Ihe cancellation procedure. ticket ID is mad
passen6er and corresponding record is searched in tfte Passenger. JI the
record exists, it is deleted. After deleting the record (if it is confinned), first record
with wailing status for the samc train and sgmc ca‹cgory are scorched from ‹he
Passenger iablc and its 6\a‹us is changed to confirm.
ENTITES ATTR IBUTES
Aødhat no
State
Security ques
S¢cuõ ty ans
Booked by
Reservation status
Train
B seersI
WScasl
W scełs3
BooLcó user
TRAI
id assen
BOOKS
RGACHEß
siaiion no
lesen user id
TRAIN
CANCEL
BOOKS
STA RTS REACHES
5TOfi8 AT
FINAL LIST OR RfiLATION SHIPS:
• books -T¢mory relation ship hmwccn [Link] ‹tn‹l
1”IFKEY.
• starts -Between TRAIN and STATION
• reochcs —Between TRAJN and STATION
• cancel —Between USER and TJCKET
• s‹op.s_at —ßctlvecn TRAIN and STATION
CRGATG COMMANDS:
crcatc tabTc if not exist USER(user id int primary k¢[Link] nsmc
va›chart50),lasl name varchar{SO),adhar no varcI\ar{20),ge‹tder char,age
int,mobilg eta varChar{50),emcil varchBg50),city ›'archar{30),state
vazchar(5O),pincode varcfiarY20), ssword varchar(30),secuzity ques
varcliar{5O),sccurity ans varchar(30));
create table if not ex sists TRAJN(train no inl primary key,train name
varchar{50),arrival time time,depariure time time,avai1ability of seats char,date
dale);
creale table i£ not exisfs STATION(no inl ,name varchart50),hau\t int,arrival time
time,train noint,prinuiry key(station no,train no),constarint f'oroign key(train no)
references TRAIN( trsin no));
create table if not exsi8ts TRAIN STATUS(tniin no int primuy Ley,b seats I
int,b seats2 int,a seats I int,a seats2 int,w soals I int,w seaTs2 in\,f'aIcI floa\,fare2
char,no of nssertgm int,1rain no int,conslmint tbzuign Ley(user id) references
USER(user id),constraint foreign 1ey(train no) references TRAIN(train no));
cmatc table if not cxieu PASSENGER(passenger id inf primary key,pnr no
int,age inl,gender char,user id inl,wservation stalus chBr,seat number
varcliar{5),name varchar{3O),ticket id int,constrainz foreign key(user id)
references USER(user id),constraint fomign key(ticket id) references
TICKET(id)):
creale tab1t if not exsists STARTS( main no int primczy kcy,stntion nu
int,constIaint foreign key(main no) refcwnces TRAIN(tmin no),cons\rain1 foreign
key(sIalion no) references STATION(no));
create table if not cxsi8ts STOf'S ATt train no [Link] ri+ int,conslIaint I+reign
Ley(main no) references TItAfN(train no),constrain\ fbroign Loy(station no)
references STATION{no));
create table if” nut exsists REACH CS(train no ini,slnlion no inI,tim<
time,constraint fbrei n key(train no) reférences TRAIN(train no),constraint
foreign key(xta1ion no) references STATION(no));
create t8blc if not cxsi8ts BOOKS( u or id int,id [Link] forciym key(user id)
refewnces US£R(user id),conslraint foreign Let(id) references TICKET(id)).
create tgblc if no{ cxsists CANCEL(user_id int,id int,yassengcr id inf,constr8int
foreign keyt id) n fcrcnccs TICKET(id),consttaint forei keytpaascngcr ids
mfemnces PASSENGER(passenger id),constraint for¢ip ke tu« r id) r
¢fe›cnces USER(user id));
!N5ERT QUERIES:
insert into
USER(uscr_id,first namc,lasf_nainc.8adftar no,[Link]\c [Link],city,st
atc,yincodc, aSsword,sccurity qucs,sccuñfy_ansJ
values( 1701.'vijay','sharma','309887340843','M',34,'9gS778ft655','vijay I [Link]
m','vijayawada','andhrapradnh','Ji2000l','l234Ji #','fâvouritecolour','rcd’),(J702,'r
ohitft’.'kumar'.'45670987l234','M',4S,'98096GG535','rohithI kuma [Link]’.'gu
ntur','andhrapradesh','522004’,'12@#34S','favountcbike’,'bn w'),( l703,'manasvi’,'sre
e','765b43210987’.'F',2t›,’9995550G66'.'nianasvi57 [Link]’,’guntur','andhra
pmdesh','522004'.’0987hii’,'favourite fJower’,’rose’),
insert into TRAIN{t›ain [Link] namc,arriva1 tim¢.Jeparturc timc,avoi\cbi1ity où
seats,date) va lues( 1 271 1.'pinatini
cap',’ 1 13000’.' I 14000‘,’A',20l704l0),(123l5,’comiandel
exp'.'1 24500’, l 25000’,’NA’,20170410):
inseo into STATION(flo,ramc,hault,awival time,tmin no)
values( 1 l1,’vijayawad a’.10.' 1 1 3000’,1 27 11 ),(223.'tirupaihi',5,’114500’, 13315);
TRAIN STATUSt main no.w soat8 I.b coats I.b scats2,a scatsl,a scats2.w scats
2,farr1,fare2) values( 127a l. l0,4,O, l. I.0, l00,430),(I 23t5, l0,3.0,0,2,1,300,600),
inseri into TICKET([Link] id,status,no of asscngcrs,tr8in no)
values(4001,170l,’C‘, I.,I2?T I ),{4002, 1703.'NC', I ,12315),
in'u•rt into PA 5SCNGERSfpassenger id,pnr no,agegendcr,uscr id,rcscrvation
sIa‹us,scat numbcr,[Link]¢t id) valucs('i0O|,7ft965,4S.’M', T 70),'C',’B/i-
4S','nimesh',4001),(5002.S4523,S4,'F', t70I ,'W','B3-2I','surckhg',4002);
insert into START$(train no,station no) values( 127 1 1, 1 1 1),(123 1 5,222);
insert into STOPS AT(train nu,station no) values(I 271 1 ,222j,( \ 23l5,T 11);
inscrt into REACHES(tr8in nn,statinn [Link]) valuustt27l 1,222.'040000'),
t 123 1 S,I I t,'051500').
insert into BOOKS(user id,id) values(I70l,400l ),(J 702,4002};
insert into CANCEL(user [Link] id) values(\ 701,400 1 ,s00l ),
[Link] user id anlt nam¢ of all fhosc user wlto booked ticket Sof pitiakini expmas
select [Link] id,cdncat([Link] name,[Link] name}as name
[Link]\ ‹Jetsisl of pass+ngcn travelling under tick 'I ao 4001
where ticket id like 400l ;
3. display all tltose main no's vhich reach station no --
where t train [Link] no and [Link] [Link] and [Link] file 'vijayawada';
4. display lime al which t‹ain no----- reaches station no ------
where [Link] [Link];
fi. ‹display details ofaTl fhosc us¢rs who canclcd wickets fbr train no-----
where [Link] id=[Link] id acd [Link] and \.train oo like 12711 ;
6. dip1ay the main nu. with increasing urd+r õf lhc Maros of class I
where t
order by hare I asc:
lion passcngw p,train t,úckct tc
where [Link] [Link] no and [Link] id and I.1zain namo like
8. ‹ti play immediate tmin from lirupalhi la V ijayawada
where [Link] no xelect no from station where name like ’hrupathi')
and sa.sta1ion no=(aelent no from station where name like 'vijsyawada’)
order by date.
9. display the train no which hsulls for more time in station no--—-----
having max(hault);
[Link] details of all those passengers whue status is confirmed for twin no
where [Link] like 'c' and [Link] ne=I27l1;
Tn our project Railway rczcrya\ion sjrsicm we hew stored all Ihe inTorzneTion about the Trains
schodutcñ and ‹he users booLinlt iiclu'is gnd even steius cF trains, sees ccc This dale bese is
helpful for Ae rlpgTicotions which TociTilole pasaengera to book tile coin tiekc\e and shock be
deceits of ttains and their slalus from ‹heir nl¥ce lull it uvcids inconvinimccs oF yoinj; lo
We had coneid<zod the most inypoztnnl