SlideShare a Scribd company logo
Database and Web Database System
PT1081156 - Individual Assignment Page 1
APIIT SD INDIA
CE00318-2 (DWDS)
Database and Web Database Systems
INDIVIDUAL ASSIGNMENT
ONLINE RAILWAY RESERVATION SYSTEM
Submitted By: - Module Lecturer:-
Piyush Kumar Sulekh Sharma
PT1081156
Database and Web Database System
PT1081156 - Individual Assignment Page 2
Table of Contents
1. INTRODUCTION.....................................................................................................................................3
2. PROPOSED SOLUTION...........................................................................................................................4
3. Entity Relationship Diagram..................................................................................................................5
3.1 List Of Entity types: .............................................................................................................................5
3.2 List of Relationships: ...........................................................................................................................5
3.3 Entity Relationship Diagram: ..............................................................................................................6
4. Mapping of ERD to Relational Model....................................................................................................7
5. Normalization........................................................................................................................................9
Initial Database Schema............................................................................................................................9
5.1 FIRST NORMAL FORM(1NF) ..............................................................................................................10
5.2 SECOND NORMAL FORM (2NF).........................................................................................................11
5.3 RELATIONS IN THIRD NORMAL FORM (3NF).....................................................................................11
6. TABLE DESIGN & STRUCTURE .............................................................................................................12
7. QUERIES ..............................................................................................................................................18
7.1 DDL_STATEMENTS ............................................................................................................................18
7.2 DML STATEMENTS ............................................................................................................................20
8. FORM DESIGN .....................................................................................................................................24
9. REPORTS..............................................................................................................................................30
10. TOOLBAR.........................................................................................................................................32
11. REFERENCES AND CITATION ...........................................................................................................33
Database and Web Database System
PT1081156 - Individual Assignment Page 3
1.INTRODUCTION
This system is basically concerned with the reservation and cancellation of railway tickets to the
passenger. The need of this system arouse because as is the known fact that India has the largest
railway network in the whole world and it is not possible to handle such a large system manually.
By computerizing it, it became possible to overcome the limitations and make the system
operations more efficient. The complexity in handling data and records of such a vast system got
reduced and became easier by computerizing the system.
Being more specific, this online railway reservation system can perform the basic functions like
reservation and cancellation. The users are required to register on the server for getting access to
the database and query result retrieval. Upon registration completion, each user has an account
which is essentially referred to as the ‘view level’ of the customer. The account contains
comprehensive information of the user entered during the registration and allows the user to
access their past reservations, cancellations, enquire about trains and train schedule, seat
availability and make afresh reservations. The user will also be able to update their account
details, etc.
The master user of this system is the Railway Administrator who can login using a master
password and once a user is authenticated as the admin, he/she can access and modify
information stored in the database of this system. This includes adding and updating of train,
station, train routes and also managing the user and the passenger details.
Database and Web Database System
PT1081156 - Individual Assignment Page 4
2.PROPOSED SOLUTION
The railway network is a very vast system to be handled manually and its computerization will
prove to be of great help to both the employees and the passengers. The customer and the admin
are the two parties which are allowed to have access to the database of the system and have
different view level schemas’ to the database information.
The customers are privileged with the following services:
Register as a customer by providing certain personal details.
Make fresh reservations and book one or more (limited to 3 seats per ticket) seats.
View past booking and can even do cancellation of booked ticket.
See trains between a pair of stations, check seat availability in trains and get the fare
details.
Administrator is privileged with the following services:
Login as the master user using a master password
Add train, station, and route
See user and passenger details and can even delete their profiles after which the user will
not be able to login to the system as a user.
The system’s security has been kept into consideration well. The database of the system cannot
be accessed by any user either admin or customer without being authenticated by correct
username and password. The password set can also be modified and in case if the user forgets the
password, it can be recovered by giving a correct answer to a security question.
This project has been designed in such a way so that it overcomes problems like data
redundancy.
Database and Web Database System
PT1081156 - Individual Assignment Page 5
3.Entity Relationship Diagram
3.1 List of Entity types:
S. no Entity Attributes
1 User Email_ID, password, Fullname, Gender, Age, Mobile,City, State
2 Passenger PNR ,Passenger_name,Age, Gender,
Reservation_status,Booked_By
4 Train Train_ID, Train_name,Train_type,Available_days,Seat_available
5 Route Source_distance, Stop_number, Arrival_time, Departure_time
6 Station Station_ID, Station_Name
7 Train_Status Available_Date, Booked_seats1, Waiting_seats1,
Available_seats1, Booked_seats2, Waiting_seats2,
Available_seats2, Booked_seats3, Waiting_seats3,
Available_seats3
3.2 List of Relationships:
S.no. Relation Type Entity Types Involved
1 Enquires User, Train
2 Consists Of Station, Route
3 Has Train, Train_Status
4 Checks User, Train_Status
5 Has Train, Route
6 Starts from/ Ends on Train, Station
7 Assigns User, Passenger
Database and Web Database System
PT1081156 - Individual Assignment Page 6
3.3 Entity Relationship Diagram:
User
Email IdPassword
State
Mobile
Age
Gender
Full Name
Security-Question
City
Available_Date
Waiting_seats1
Security-Answer
Waiting_seats2
Waiting_seats3
Available_seats1
Available_seats2
Available_seats3
Booked_seats1
Booked_seats2
Booked_seats3
Books
Has
Dates
Status
M
1
Passenger
Passenger_Name
PNR
Age
Gender
Booked_By
Reservation_status
Seat_number
Show
source
Show
Destination
Station
Station_Id
Station_Name
Train
Train_Id
Train_Name
Train_Type
Available_Class
HasStrars
From
End At
Consist Of
Arrival_Time
Departure_Time
Stop_Number
Source_Distance
Has
Fare_Class1
Fare_Class2
Fare_Class3
Seat_Class1 Seat_Class2
Seat_Class1
N
M
1
M
N
N
N
N
N
N
1
1
1
1
1
N M
1
1
M
Train_Status
RouteRoute
RouteTrain_Class
Database and Web Database System
PT1081156 - Individual Assignment Page 7
4.Mapping of ERD to Relational Model
Step 1: Mapping of Strong Entity Type
S.no Entity Type Relation
1 User User (Email_ID, username, gender, age, mobile, Password)
2 Passenger Passenger (PNR ,Gender, Passenger_name, Age,Booked_By)
3 Train Train (Train_id, Train_name, Days_available, Train_type)
4 Station Station (Station_ID, Station_name)
Step 2: Mapping of Weak Entity Type:
S.no Entity Type Relation
1 Route Route(Train_ID, Stop_number ,Source_distance, Arrival_time,
Departure_time)
2 Train_status Train_status(Train_ID, Available_Date, Booked_seats1,
Waiting_seats1, Available_seats1, Booked_seats2, Waiting_seats2,
Available_seats2, Booked_seats3, Waiting_seats3, Available_seats3)
Step 3: Mapping Of 1:M Relationship:
Relation Entities Approach Relation
Starts
From
Train,Station Foreign Key Train(Train_ID,Train_name,Days_available,
Train_type,Fare_class1, Fare_class2,
Fare_class3, Seats_class1, Seats_class2,
Seats_class3)
Ends at Train, Station Foreign Key Train(Train_ID,Train_name,Days_available,
Train_type,Fare_class1, Fare_class2,
Fare_class3, Seats_class1, Seats_class2,
Seats_class3)
Show
Source
Station,
Passenger
Foreign Key Passenger (PNR, Seat_number, Class, Name,
Age, Gender, Fare , Source_ ID)
Show
Destination
Station,
Passenger
Foreign Key Passenger (PNR, Seat_number, Class, Name,
Age, Gender, Fare , Destination_ ID)
Database and Web Database System
PT1081156 - Individual Assignment Page 8
Step 3: Mapping Of M:N Relationship:
Relation Entities Approach Relation
Consists
of
Station, Route Cross-reference Route_HAS_Station(Station_ID,Train_ID,
Stop_number)
Step 5: Mapping Of n-ary Relationship:
Relation Entities Approach Relation
Books User, Passenger,
Train_status
Cross-reference Books(EmailID, PNR , Train_ID,
Available_Date, Reservation_Date,
Reservation_status)
Database and Web Database System
PT1081156 - Individual Assignment Page 9
5. Normalization
Initial Database Schema
 User
EmailID FullName Password Age Gender Mobile City
State Security_question Security_answer
 Train
Train_ID Train_name Train_type Seats_class1 Seats_class2
Seats_ class3 Fare_class1 Fare_class2 Fare_class3 Available_days
Source_ID Destination_ID
 Station
Station_ID Station_Name
 Passenger
PNR Passenger_name Gender Age Seat_no Class Fare Source_
ID
Destination
ID
 Route
Train_ID Stop_number Source_distance Arrival_time Departure_time
 Train Status
Train_ID Available_ Date Booked_
seat1
Booked_
seat2
Booked_
seat3
Waiting_
seat1
Waiting_seat2 Waiting_seats3 Available
_seats1
Available
_seats2
Available
_seats3
 Consist_of
Station_ID Train_ID Stop_number
 Reservation
EmailID, PNR Train_ID Available_Date
Reserved_status Reservation_Date
Database and Web Database System
PT1081156 - Individual Assignment Page 10
5.1 FIRST NORMAL FORM(1NF)
Relations already in 1NF
USER
STATION
TRAIN_STATUS
ROUTE
RESERVATION
ROUTE_HAS_STATION
Relations not in 1NF
PASSENGER
TRAIN
RELATIONS AFTER FIRST NORMAL FORM(1NF)
(PASSENGER) after 1NF
 Passenger_ticket
PNR Class Type Fare Source_ID Destination_ID
 Passenger
PNR Seat number Passenger_name Age Gender
(TRAIN) after 1NF
 Train_days
Train_ID Days_Available
 Train
Train_ID Train_Name Train_type Source_ID
Destination_ID Seats_class1 Fare_class1 Seats_class2
Fare_class2 Seats_class3 Fare_class3
Database and Web Database System
PT1081156 - Individual Assignment Page 11
5.2 SECOND NORMAL FORM (2NF)
RELATIONS IN 2NF
User
Station
Route_HAS_Station
Train_status
Route
Reservation
Passenger
Passenger_ticket
Train
Train_class
5.3 RELATIONS IN THIRD NORMAL FORM (3NF)
RELATIONS IN 3NF
User
Station
Route_HAS_Station
Train_status
Route
Reservation
Passenger
Passenger_ticket
Train
Train_class
Database and Web Database System
PT1081156 - Individual Assignment Page 12
6.TABLE DESIGN & STRUCTURE
1) TRAIN
CONSTRAINTS:
PRIMARY KEY: Train_ID
FOREIGN KEY: Source_ID, Destionation_ID
2) TRAIN_CLASS
CONSTRAINTS:
PRIMARY KEY: Train_ID
FOREIGN KEY: --
Database and Web Database System
PT1081156 - Individual Assignment Page 13
3) DAYS_AVAILABLE
CONSTRAINTS:
PRIMARY KEY: Train_ID
FOREIGN KEY: -- Train_ID
4) STATION
CONSTRAINTS:
PRIMARY KEY: Station_ID
FOREIGN KEY:--
Database and Web Database System
PT1081156 - Individual Assignment Page 14
5) PASSENGER
CONSTRAINTS:
PRIMARY KEY: PNR
FOREIGN KEY: Train_ID
6) PASSENGER_TICKET
CONSTRAINTS:
PRIMARY KEY: PNR
FOREIGN KEY: Train_ID
Database and Web Database System
PT1081156 - Individual Assignment Page 15
7) TRAIN_STATUS
CONSTRAINTS:
PRIMARY KEY: Train_ID, Available_Date
FOREIGN KEY: Train_ID
8) ROUTE
CONSTRAINTS:
PRIMARY KEY: Train_ID, Stop_number
FOREIGN KEY: Train_ID
Database and Web Database System
PT1081156 - Individual Assignment Page 16
9) ROUTE_HAS_STATION
CONSTRAINTS:
PRIMARY KEY: Train_ID,Station_ID
FOREIGN KEY: Station_ID
10) USER
CONSTRAINTS:
PRIMARY KEY: EmailID
FOREIGN KEY:
Database and Web Database System
PT1081156 - Individual Assignment Page 17
11) ADMIN
CONSTRAINTS:
PRIMARY KEY: UserID
FOREIGN KEY:
12) RESERVATION
CONSTRAINTS:
PRIMARY KEY: PNR,EmailID,Available_Date,PNR
FOREIGN KEY:--
Database and Web Database System
PT1081156 - Individual Assignment Page 18
7.QUERIES
7.1 DDL_STATEMENTS
1) TRAIN
create table Train (Train_ID int not null, Train_name varchar(50) not null, Train_type
varchar(50) not null, Source_stn varchar(30) null, Destination_stn varchar(30) null, Source_ID
varchar(8) null, Destination_ID varchar(8) null, primary key(Train_ID), foreign key(Source_ID)
references Station(Station_ID) on update cascade on delete cascade, foreign key
(Destination_ID) references Station(Station_ID) on update no action on delete no action)
2) TRAIN_CLASS
create table Train_class (Train_ID int not null, Fare_Class1 int not null, Seat_Class1 int not null,
Fare_Class2 int not null, Seat_Class2 int not null,Fare_Class3 int not null, Seat_Class3 int not
null, primary key(Train_ID))
3) DAYS_AVAILABLE
Create table Days_Available(Train_ID int not null, Available_days varchar(20), primary
key(Train_ID))
4) STATION
Create table Station(Staiton_ID int not null, Station_Name varchar(25), primary key(Station_ID)
)
5) PASSENGER
create table Passenger ( PNR varchar(25) not null, Seat_number int not null, Passenger_name
varchar(30) not null, Age int not null, Gender varchar(8) not null, Train_ID int not null,foreign
key(Train_ID) references Train(Train_ID) on update cascade on delete cascade, primary
Database and Web Database System
PT1081156 - Individual Assignment Page 19
key(PNR, Seat_number) )
6) PASSENGER_TICKET
create table Passenger_ticket ( PNR varchar(25) not null, Source_ID varchar(8) not null,
Destination_ID varchar(8) not null, Class_type varchar(50) not null, Reservation_status
varchar(25) not null, Train_ID int not null,foreign key(Train_ID) references Train(Train_ID) on
update cascade on delete cascade, primary key(PNR) )
7) RESERVATION
create table Reservation (Train_ID int not null, Available_Date varchar(20) not null, EmailID
varchar(30) not null, PNR varchar(20) not null, Reservation_Date text not null,
Reservation_Status varchar(20) null, foreign key(Train_ID,Available_Date) references
Train_status1 (Train_ID,Available_Date) on update cascade on delete cascade, foreign
key(EmailID) references User_table(EmailID) on update cascade on delete cascade, primary
key(Train_ID,Available_Date,EmailID,PNR) )
8) TRAIN_STATUS
create table Train_status3 (Train_ID int not null, Available_Date varchar(20) not null,
Booked_seats3 int null, Waiting_seats3 int null, Available_seats3 int null, primary
key(Train_ID,Available_Date), foreign key(Train_ID) references Train(Train_ID) on update
cascade on delete cascade)
9) ROUTE
create table Route (Train_ID int not null, Stop_number int not null, Station_ID varchar(8) not
null , Arrival_time text not null, Departure_time text not null, Source_distance int not null,
primary key(Train_ID,Stop_number), foreign key(Train_ID) references Train(Train_ID) on
update cascade on delete cascade)
Database and Web Database System
PT1081156 - Individual Assignment Page 20
10) ROUTE_HAS_STATION
create table Route_HAS_Station (Train_ID int not null,Station_ID varchar(20) not null,
Stop_number int not null, primary key(Train_ID, Station_ID))
11) USER
Create table User_table ( EmailID varchar(30) not null, Password varchar(15) not null, FullName
varchar(30) not null, Gender varchar(8) not null, Age int not null, Mobile varchar(14) not null,
City varchar(20) not null, State varchar(25) not null, Security_question varchar(40) not null,
Security_answer varchar(20) not null )
12) ADMIN
create table Admin_table (User_ID varchar(20) not null, Password varchar(15) not null, primary
key(User_ID))
7.2 DML STATEMENTS
INSERT STATEMENTS
Adding a new Station – This step is used to add a new station to the station table where the
admin provides the station name and the station id by which it will be recognized.
insert into Station values('" + txt_id.Text + "','" + txt_name.Text + "' )
Adding a Route – Data is inserted into the Route table.
Table route receive entries of train id, stop number, station id, arrival time, departure time and
the source distance.
insert into Route values('" + txt_trainid2.Text + "','" + txt_stopno.Text + "','"+txt_stnid.Text +"','"
+ txt_arrival.Text + "','" + txt_departure.Text + "','" + txt_distance.Text + "')
UPDATE STATEMENTS
Database and Web Database System
PT1081156 - Individual Assignment Page 21
Update Station
update Station set Station_ID='" + txt_id.Text + "' where Station_name ='" + txt_name.Text + "'
Update Train
update Train set Train_name= '" + txt_trainname.Text + "', Train_type='" +
ddl_type.SelectedItem + "',Source_stn='" + ddl_source.SelectedItem + "',
Destination_stn='" + ddl_dest.SelectedItem + "' where Train_ID='"+txt_trainid.Text +"'
RESERVATION QUERIES
RESERVATION
Read data from Station table and get Source Station ID
SqlCommand cmd = new SqlCommand("Select * from Station where Station_name ='" +
ddl_source.SelectedItem.ToString() + "'", con1);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
txt_sid.Text = dr["Station_ID"].ToString();
}
dr.Close();
Read data from Station table and get Destination Station ID
SqlCommand cmd = new SqlCommand("Select * from Station where Station_name ='" +
ddl_dest.SelectedItem.ToString() + "'", con1);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
txt_did.Text = dr["Station_ID"].ToString();
}
dr.Close();
Database and Web Database System
PT1081156 - Individual Assignment Page 22
Get list of trains available on a particular date between a pair of stations
Select Route.Train_ID, Train.Train_name ,Train_status.Available_Date
FROM
Route INNER JOIN Train ON Route.Train_ID=Train.Train_ID
INNER JOIN
Train_status ON Train.Train_ID=Train_status.Train_ID
WHERE (Route.Station_ID IN
(SELECT Source.Station_ID
FROM Route AS Source INNER JOIN
Route AS Destination ON Source.Train_ID =
Destination.Train_ID
WHERE (Source.Stop_number - Destination.Stop_number < 0) AND
(Source.Station_ID = @Source) AND (Destination.Station_ID = @Dest))) AND
(Train_status.Available_Date = @Available_Date)
Get seat status from table Train_status and display it when user selects the class from
dopdownlist provided
SqlCommand cmd = new SqlCommand("Select * from Train_status where Train_ID ='" +
lbl_id.Text.ToString() + "'and Available_Date='" + txt_date.Text + "'", con1);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
lbl_seats.Text = dr["Available_seats1"].ToString();
Label7.Text = "Total available seats in "+lbl_class.Text +" are : ";
lbl_msg.Text = "Total Seats already booked: ";
lbl_booked.Text = dr["Booked_seats1"].ToString();
}
dr.Close();
Calculate Fare form the Journey distance from the selected source and destination
stations
SqlCommand K = new SqlCommand("Select * from Route where Train_ID ='" +
lbl_id.Text.ToString() + "' and Station_ID='" + txt_sid.Text + "'", kon);
SqlDataReader dr2 = K.ExecuteReader();
while (dr2.Read())
{
distance1.Text = dr2["Source_distance"].ToString();
}
dr2.Close();
SqlCommand Kk = new SqlCommand("Select * from Route where Train_ID ='" +
lbl_id.Text.ToString() + "' and Station_ID='" + txt_did.Text + "'", kon);
SqlDataReader dr3 = Kk.ExecuteReader();
Database and Web Database System
PT1081156 - Individual Assignment Page 23
while (dr3.Read())
{
distance2.Text = dr3["Source_distance"].ToString();
}
dr3.Close();
int distance = (Convert.ToInt32(distance2.Text) - Convert.ToInt32(distance1.Text));
SqlCommand cmd = new SqlCommand("Select * from Train_class where Train_ID ='" +
lbl_id.Text.ToString() + "'", con1);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
lbl_X.Text = dr["Fare_Class1"].ToString();
}
int Y = Convert.ToInt32(lbl_X.Text);
int fare = Y * Convert.ToInt32(ddl_seats.Text)*distance ;
After Fare calculation, add passengers details to successfully complete the reservation
process
int a = Convert.ToInt32(lbl_seats.Text);
int booked = Convert.ToInt32(lbl_booked.Text);
SqlCommand cmd = new SqlCommand("insert into Passenger values('" + pnr + "','" + a + "','" +
txt_pname1.Text + "','" + txt_age1.Text + "','" + ddl_gender1.SelectedItem + "','" + lbl_id.Text +
"','" + lbl_email.Text + "')", conn);
cmd.ExecuteNonQuery();
CANCELLATION QUERIES
CANCELLATION
When user cancels a ticket, the PNR status is set as CANCELLED
update Passenger_ticket set Reservation_status = 'CANCELLED' where PNR="+txt_PNR.Text
+""
With the cancellation of one ticked, available seats in Train_status table for that specific
train should increase and booked seats should decrease by 1
update train_status set Available_seats1=Available_seats1+1 and Booked_seats1=
Booked_seats1-1 where Train_ID=’”+lbl_id.Text+”’ and Available_Date=’”+lbl_date.Text+”’
Database and Web Database System
PT1081156 - Individual Assignment Page 24
8.FORM DESIGN
1) NEW REGISTRATION – USER
DESCRIPTION: Any user coming to this page can register to the website by providing required
details. The details being provided should not violate the validation rules otherwise registration
will not be allowed.
2) LOGIN PAGE – ADMIN, USER
DESCRIPTION: Registered users login to the website by using a specific EmailID and
password. This will redirect the user to a different view level where the user will be availed
various services like reservation, cancellation, etc.
Database and Web Database System
PT1081156 - Individual Assignment Page 25
3) ADD TRAIN
DESCRIPTION: Admin of this website can add new trains to the database which will be further
allowed for reservations. Train will be assigned a Train ID which should be unique and then a
train name will also be assigned to the train for its identification.
4) ADD STATION
DESCRIPTION: The admin is privileged to add and update new stations and station IDs to the
system’s database.
Database and Web Database System
PT1081156 - Individual Assignment Page 26
5) ADD ROUTE
DESCRIPTION: Already added trains require a route to be defined which it has to follow. The
admin can use this page to add new route to the train where he/she has to add station ids and stop
numbers along with arrival and departure times.
6) TRAIN STATUS
DESCRIPTION: This page can be used to see the total available seats, booked seats and waiting
seats in particular classes of a train. The train IDs is available in the dropdown list given.
Database and Web Database System
PT1081156 - Individual Assignment Page 27
7) MANAGE PROFILES
DESCRIPTION: Admin can view the details of registered users and can also update and delete
their accounts. Users whose account will be deleted won’t be able to use the reservation/
cancellation services of the site.
8) MANAGE TRAIN
DESCRIPTION: Admin can view and update train details that have been added to the database
of this system. The admin can find trains either by providing train id or train name.
Database and Web Database System
PT1081156 - Individual Assignment Page 28
9) CHECK PNR
DESCRIPTION: Users who have reserved seats in any of the trains can enter the PNR number
provided to them and can see the status of their ticket whether it is confirm, is cancelled or is
queued in the waiting slot.
10) SEAT AVAILABILITY
DESCRIPTION: This is used to view the available seats in a particular class of a train. User can
enter the source and destination station name and the date for which they want to see the
availability of seats.
Database and Web Database System
PT1081156 - Individual Assignment Page 29
11) VIEW SCHEDULE
DESCRIPTION: Users can search and view train schedule and other details by proving the train
number or the train name. The user will be shown the train details like arrival departure timings
along with the route it will follow to reach to the destination station.
Database and Web Database System
PT1081156 - Individual Assignment Page 30
9.REPORTS
1) REPORT: TRAINS
Description:
The report TRAINS is used to show the list of Trains added by the admin to the database. This
consists of the train id, train name, train type, source station name, and destination station name.
This report can be downloaded in either of .pdf form or .docs form or as an excel sheet.
Admin needs to see the detailed list of the trains like the train name, its source station and the
destination station. The report also shows the type of train it is i.e., whether it is an express train
or super fast or Rajdhani etc. This report will help in the management of trains to the admin.
Database and Web Database System
PT1081156 - Individual Assignment Page 31
2) REPORT: TRAIN ROUTE
Description:
The report TRAIN ROUTE displays details of the route that trains of this website will follow. It
consists of the train id, station id where the train will stop, stop number, arrival time at the stop,
departure time from the stop and the distance of the stop from the source station.
When the user(admin) will want to see the the detailed list of trains along with its stop stations
and its timings at all its stops from source to destination, this report will be helpful so that by
viewing this report, any required changes/modifications can easily be made to the database.
Database and Web Database System
PT1081156 - Individual Assignment Page 32
10. TOOLBAR
A toolbar has been provided in the user’s view level which consists of icons like Home, Train,
and Ticket which serves as a link to the respective pages. The Home icon if clicked, redirects the
user to the Home page of the user and similarly the Power button icon allows user a proper
logout.
This icon depicts the
Home. On click of this,
user is redirected to its
homepage.
This is the Schedule icon which
takes the user to the “Check
Schedule” page
This is the Ticket icon on click of which takes the
user to the “Check Schedule” page where the user
will be able to reserve 1 or more seats in any
particular train.
The train icon redirects the user to the search train
page which allows user to search different trains
by entering the train id or the train name or even
by entering any route station.
The user can logout of the website by clicking this
icon.
Database and Web Database System
PT1081156 - Individual Assignment Page 33
11. REFERENCES AND CITATION
1) SQL JOINS
w3cschoolsadmin. (2013). SQL INNER JOIN. Available:
http://www.w3schools.com/sql/sql_join_inner.asp. Last accessed 24th April
2013.
2) SQL LEFT JOIN
w3cschoolsadmin. (2013). SQL LEFT JOIN. Available:
http://www.w3schools.com/sql/sql_left_inner.asp. Last accessed 21st April
2013.
3) SQL UPDATE
w3cschoolsadmin. (2013). SQL UPDATE. Available:
http://www.w3schools.com/sql/sql_update.asp. Last accessed 15th April
2013.
4) INSERT STATEMENTS IN SQL BY C#
marc. (2012). write insert query in c#. Available:
http://stackoverflow.com/questions/9954900/how-to-write-insert-query-in-c.
Last accessed 21st April 2013.
5) GRIDVIEW DATABINDING
Msoft. (2013). GridView.DataBind Method. Available:
http://msdn.microsoft.com/en-IN/library/fkx0cy6d.aspx. Last accessed 12th
April 2013.
6) FOREGIN KEY CONSTRAINT
w3cschoolsadmin. (2013). SQL FOREIGN KEY Constraint. Available:
http://www.w3schools.com/sql/sql_foreignkey.asp. Last accessed 18th April
2013.
7) Referred to www.indianrail.gov.in/ and www.irctc.co.in .
Database and Web Database System
PT1081156 - Individual Assignment Page 34

More Related Content

DOCX
Synopsis on railway reservation system
DOCX
Documentation of railway reservation system
PPTX
Online Railway Reservation System
DOCX
Online Railway Reservation System
PDF
Online railway reservation system
PPTX
Railway booking & management system
PDF
Railway reservation system
PDF
Railway Reservation System - Software Engineering
Synopsis on railway reservation system
Documentation of railway reservation system
Online Railway Reservation System
Online Railway Reservation System
Online railway reservation system
Railway booking & management system
Railway reservation system
Railway Reservation System - Software Engineering

What's hot (20)

PPTX
Presentation on Railway Reservation System
DOCX
Online Bus Ticket Reservation System
DOCX
ER diagrams for Railway reservation system
PPT
Train ticket reservation
PPTX
ONLINE BUS BOOKING SYSTEM
DOCX
srs for railway reservation system
PDF
Railway management system, database mini project
DOC
Bus Booking Management System
PPT
railway reservation software documentaion
PPTX
Railway reservation system
RTF
Railway Reservation Documentation
PDF
Tourism management system_REPORT.pdf
DOCX
Bus Ticket Management System Documentation
PPTX
Web based tourism system
PPTX
Online Ticket Reservation System-SRS, ERD, DFD, Structured Charts
PPTX
online bus ticket booking system
RTF
Project report-on-student-information-management-system-php-mysql
DOCX
Synopsis gor online Tourism.
DOCX
Tour guidance srs (Software Requirements Specification)
PPTX
Railway Reservation System - Requirement Engineering
Presentation on Railway Reservation System
Online Bus Ticket Reservation System
ER diagrams for Railway reservation system
Train ticket reservation
ONLINE BUS BOOKING SYSTEM
srs for railway reservation system
Railway management system, database mini project
Bus Booking Management System
railway reservation software documentaion
Railway reservation system
Railway Reservation Documentation
Tourism management system_REPORT.pdf
Bus Ticket Management System Documentation
Web based tourism system
Online Ticket Reservation System-SRS, ERD, DFD, Structured Charts
online bus ticket booking system
Project report-on-student-information-management-system-php-mysql
Synopsis gor online Tourism.
Tour guidance srs (Software Requirements Specification)
Railway Reservation System - Requirement Engineering
Ad

Viewers also liked (11)

PDF
Project report RAILWAY TICKET RESERVATION SYSTEM SAD
PPT
enhanced er diagram
PPTX
View of data DBMS
PPTX
DFMA design for manufacturing and assembly
PDF
Airline reservation system db design
PPTX
Railway Reservation System
PDF
DFM BIT Coursework
DOC
Airline reservation system documentation
PDF
Development Framework & Methods
PDF
Computer Science Investigatory Project Class 12
DOCX
Computer science project work
Project report RAILWAY TICKET RESERVATION SYSTEM SAD
enhanced er diagram
View of data DBMS
DFMA design for manufacturing and assembly
Airline reservation system db design
Railway Reservation System
DFM BIT Coursework
Airline reservation system documentation
Development Framework & Methods
Computer Science Investigatory Project Class 12
Computer science project work
Ad

Similar to Online railway reservation system (20)

DOCX
Railway Reservation system Case study of oracle db by cj date
DOCX
E-TICKETING ON RAILWAY TICKET RESERVATION
PPTX
Railway Management PPT.pptx
DOC
railway_PROJECT.doc on python my SQL connectivity
PDF
COMPUTER SCIENCE PROJECT OF RAILWAY RESERVATION SYSTEM PYTHON PROGRAMMING.pdf
PPTX
Loctrainreservation based on the train.ppt
PPTX
PPTX
Dbms presentation!!
PDF
Databasesreport
PDF
Databasesreport
PPTX
MS SQL DATABASE PROJECT ON RAILWAYS.pptx
PPTX
Railway Reservation System initial django.pptx
DOCX
cs project.docx investigatory computer science
PDF
IRJET- Railway Reservation and Route Optimization System with Implementation
DOCX
Synopsis for Online Railway Railway Reservation System
DOC
Online Bus Reservation
DOCX
PPTX
Railway Reservation System.pptx
PPTX
Railway Reservation System (2).pptx
DOCX
MS Access Database Project proposal on Airline Reservation System
Railway Reservation system Case study of oracle db by cj date
E-TICKETING ON RAILWAY TICKET RESERVATION
Railway Management PPT.pptx
railway_PROJECT.doc on python my SQL connectivity
COMPUTER SCIENCE PROJECT OF RAILWAY RESERVATION SYSTEM PYTHON PROGRAMMING.pdf
Loctrainreservation based on the train.ppt
Dbms presentation!!
Databasesreport
Databasesreport
MS SQL DATABASE PROJECT ON RAILWAYS.pptx
Railway Reservation System initial django.pptx
cs project.docx investigatory computer science
IRJET- Railway Reservation and Route Optimization System with Implementation
Synopsis for Online Railway Railway Reservation System
Online Bus Reservation
Railway Reservation System.pptx
Railway Reservation System (2).pptx
MS Access Database Project proposal on Airline Reservation System

Recently uploaded (20)

PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Complications of Minimal Access Surgery at WLH
PDF
Basic Mud Logging Guide for educational purpose
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
PDF
TR - Agricultural Crops Production NC III.pdf
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
01-Introduction-to-Information-Management.pdf
PDF
Business Ethics Teaching Materials for college
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Insiders guide to clinical Medicine.pdf
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Complications of Minimal Access Surgery at WLH
Basic Mud Logging Guide for educational purpose
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Final Presentation General Medicine 03-08-2024.pptx
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
TR - Agricultural Crops Production NC III.pdf
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
01-Introduction-to-Information-Management.pdf
Business Ethics Teaching Materials for college
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Microbial diseases, their pathogenesis and prophylaxis
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Module 4: Burden of Disease Tutorial Slides S2 2025
Insiders guide to clinical Medicine.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra
STATICS OF THE RIGID BODIES Hibbelers.pdf
Mark Klimek Lecture Notes_240423 revision books _173037.pdf

Online railway reservation system

  • 1. Database and Web Database System PT1081156 - Individual Assignment Page 1 APIIT SD INDIA CE00318-2 (DWDS) Database and Web Database Systems INDIVIDUAL ASSIGNMENT ONLINE RAILWAY RESERVATION SYSTEM Submitted By: - Module Lecturer:- Piyush Kumar Sulekh Sharma PT1081156
  • 2. Database and Web Database System PT1081156 - Individual Assignment Page 2 Table of Contents 1. INTRODUCTION.....................................................................................................................................3 2. PROPOSED SOLUTION...........................................................................................................................4 3. Entity Relationship Diagram..................................................................................................................5 3.1 List Of Entity types: .............................................................................................................................5 3.2 List of Relationships: ...........................................................................................................................5 3.3 Entity Relationship Diagram: ..............................................................................................................6 4. Mapping of ERD to Relational Model....................................................................................................7 5. Normalization........................................................................................................................................9 Initial Database Schema............................................................................................................................9 5.1 FIRST NORMAL FORM(1NF) ..............................................................................................................10 5.2 SECOND NORMAL FORM (2NF).........................................................................................................11 5.3 RELATIONS IN THIRD NORMAL FORM (3NF).....................................................................................11 6. TABLE DESIGN & STRUCTURE .............................................................................................................12 7. QUERIES ..............................................................................................................................................18 7.1 DDL_STATEMENTS ............................................................................................................................18 7.2 DML STATEMENTS ............................................................................................................................20 8. FORM DESIGN .....................................................................................................................................24 9. REPORTS..............................................................................................................................................30 10. TOOLBAR.........................................................................................................................................32 11. REFERENCES AND CITATION ...........................................................................................................33
  • 3. Database and Web Database System PT1081156 - Individual Assignment Page 3 1.INTRODUCTION This system is basically concerned with the reservation and cancellation of railway tickets to the passenger. The need of this system arouse because as is the known fact that India has the largest railway network in the whole world and it is not possible to handle such a large system manually. By computerizing it, it became possible to overcome the limitations and make the system operations more efficient. The complexity in handling data and records of such a vast system got reduced and became easier by computerizing the system. Being more specific, this online railway reservation system can perform the basic functions like reservation and cancellation. The users are required to register on the server for getting access to the database and query result retrieval. Upon registration completion, each user has an account which is essentially referred to as the ‘view level’ of the customer. The account contains comprehensive information of the user entered during the registration and allows the user to access their past reservations, cancellations, enquire about trains and train schedule, seat availability and make afresh reservations. The user will also be able to update their account details, etc. The master user of this system is the Railway Administrator who can login using a master password and once a user is authenticated as the admin, he/she can access and modify information stored in the database of this system. This includes adding and updating of train, station, train routes and also managing the user and the passenger details.
  • 4. Database and Web Database System PT1081156 - Individual Assignment Page 4 2.PROPOSED SOLUTION The railway network is a very vast system to be handled manually and its computerization will prove to be of great help to both the employees and the passengers. The customer and the admin are the two parties which are allowed to have access to the database of the system and have different view level schemas’ to the database information. The customers are privileged with the following services: Register as a customer by providing certain personal details. Make fresh reservations and book one or more (limited to 3 seats per ticket) seats. View past booking and can even do cancellation of booked ticket. See trains between a pair of stations, check seat availability in trains and get the fare details. Administrator is privileged with the following services: Login as the master user using a master password Add train, station, and route See user and passenger details and can even delete their profiles after which the user will not be able to login to the system as a user. The system’s security has been kept into consideration well. The database of the system cannot be accessed by any user either admin or customer without being authenticated by correct username and password. The password set can also be modified and in case if the user forgets the password, it can be recovered by giving a correct answer to a security question. This project has been designed in such a way so that it overcomes problems like data redundancy.
  • 5. Database and Web Database System PT1081156 - Individual Assignment Page 5 3.Entity Relationship Diagram 3.1 List of Entity types: S. no Entity Attributes 1 User Email_ID, password, Fullname, Gender, Age, Mobile,City, State 2 Passenger PNR ,Passenger_name,Age, Gender, Reservation_status,Booked_By 4 Train Train_ID, Train_name,Train_type,Available_days,Seat_available 5 Route Source_distance, Stop_number, Arrival_time, Departure_time 6 Station Station_ID, Station_Name 7 Train_Status Available_Date, Booked_seats1, Waiting_seats1, Available_seats1, Booked_seats2, Waiting_seats2, Available_seats2, Booked_seats3, Waiting_seats3, Available_seats3 3.2 List of Relationships: S.no. Relation Type Entity Types Involved 1 Enquires User, Train 2 Consists Of Station, Route 3 Has Train, Train_Status 4 Checks User, Train_Status 5 Has Train, Route 6 Starts from/ Ends on Train, Station 7 Assigns User, Passenger
  • 6. Database and Web Database System PT1081156 - Individual Assignment Page 6 3.3 Entity Relationship Diagram: User Email IdPassword State Mobile Age Gender Full Name Security-Question City Available_Date Waiting_seats1 Security-Answer Waiting_seats2 Waiting_seats3 Available_seats1 Available_seats2 Available_seats3 Booked_seats1 Booked_seats2 Booked_seats3 Books Has Dates Status M 1 Passenger Passenger_Name PNR Age Gender Booked_By Reservation_status Seat_number Show source Show Destination Station Station_Id Station_Name Train Train_Id Train_Name Train_Type Available_Class HasStrars From End At Consist Of Arrival_Time Departure_Time Stop_Number Source_Distance Has Fare_Class1 Fare_Class2 Fare_Class3 Seat_Class1 Seat_Class2 Seat_Class1 N M 1 M N N N N N N 1 1 1 1 1 N M 1 1 M Train_Status RouteRoute RouteTrain_Class
  • 7. Database and Web Database System PT1081156 - Individual Assignment Page 7 4.Mapping of ERD to Relational Model Step 1: Mapping of Strong Entity Type S.no Entity Type Relation 1 User User (Email_ID, username, gender, age, mobile, Password) 2 Passenger Passenger (PNR ,Gender, Passenger_name, Age,Booked_By) 3 Train Train (Train_id, Train_name, Days_available, Train_type) 4 Station Station (Station_ID, Station_name) Step 2: Mapping of Weak Entity Type: S.no Entity Type Relation 1 Route Route(Train_ID, Stop_number ,Source_distance, Arrival_time, Departure_time) 2 Train_status Train_status(Train_ID, Available_Date, Booked_seats1, Waiting_seats1, Available_seats1, Booked_seats2, Waiting_seats2, Available_seats2, Booked_seats3, Waiting_seats3, Available_seats3) Step 3: Mapping Of 1:M Relationship: Relation Entities Approach Relation Starts From Train,Station Foreign Key Train(Train_ID,Train_name,Days_available, Train_type,Fare_class1, Fare_class2, Fare_class3, Seats_class1, Seats_class2, Seats_class3) Ends at Train, Station Foreign Key Train(Train_ID,Train_name,Days_available, Train_type,Fare_class1, Fare_class2, Fare_class3, Seats_class1, Seats_class2, Seats_class3) Show Source Station, Passenger Foreign Key Passenger (PNR, Seat_number, Class, Name, Age, Gender, Fare , Source_ ID) Show Destination Station, Passenger Foreign Key Passenger (PNR, Seat_number, Class, Name, Age, Gender, Fare , Destination_ ID)
  • 8. Database and Web Database System PT1081156 - Individual Assignment Page 8 Step 3: Mapping Of M:N Relationship: Relation Entities Approach Relation Consists of Station, Route Cross-reference Route_HAS_Station(Station_ID,Train_ID, Stop_number) Step 5: Mapping Of n-ary Relationship: Relation Entities Approach Relation Books User, Passenger, Train_status Cross-reference Books(EmailID, PNR , Train_ID, Available_Date, Reservation_Date, Reservation_status)
  • 9. Database and Web Database System PT1081156 - Individual Assignment Page 9 5. Normalization Initial Database Schema  User EmailID FullName Password Age Gender Mobile City State Security_question Security_answer  Train Train_ID Train_name Train_type Seats_class1 Seats_class2 Seats_ class3 Fare_class1 Fare_class2 Fare_class3 Available_days Source_ID Destination_ID  Station Station_ID Station_Name  Passenger PNR Passenger_name Gender Age Seat_no Class Fare Source_ ID Destination ID  Route Train_ID Stop_number Source_distance Arrival_time Departure_time  Train Status Train_ID Available_ Date Booked_ seat1 Booked_ seat2 Booked_ seat3 Waiting_ seat1 Waiting_seat2 Waiting_seats3 Available _seats1 Available _seats2 Available _seats3  Consist_of Station_ID Train_ID Stop_number  Reservation EmailID, PNR Train_ID Available_Date Reserved_status Reservation_Date
  • 10. Database and Web Database System PT1081156 - Individual Assignment Page 10 5.1 FIRST NORMAL FORM(1NF) Relations already in 1NF USER STATION TRAIN_STATUS ROUTE RESERVATION ROUTE_HAS_STATION Relations not in 1NF PASSENGER TRAIN RELATIONS AFTER FIRST NORMAL FORM(1NF) (PASSENGER) after 1NF  Passenger_ticket PNR Class Type Fare Source_ID Destination_ID  Passenger PNR Seat number Passenger_name Age Gender (TRAIN) after 1NF  Train_days Train_ID Days_Available  Train Train_ID Train_Name Train_type Source_ID Destination_ID Seats_class1 Fare_class1 Seats_class2 Fare_class2 Seats_class3 Fare_class3
  • 11. Database and Web Database System PT1081156 - Individual Assignment Page 11 5.2 SECOND NORMAL FORM (2NF) RELATIONS IN 2NF User Station Route_HAS_Station Train_status Route Reservation Passenger Passenger_ticket Train Train_class 5.3 RELATIONS IN THIRD NORMAL FORM (3NF) RELATIONS IN 3NF User Station Route_HAS_Station Train_status Route Reservation Passenger Passenger_ticket Train Train_class
  • 12. Database and Web Database System PT1081156 - Individual Assignment Page 12 6.TABLE DESIGN & STRUCTURE 1) TRAIN CONSTRAINTS: PRIMARY KEY: Train_ID FOREIGN KEY: Source_ID, Destionation_ID 2) TRAIN_CLASS CONSTRAINTS: PRIMARY KEY: Train_ID FOREIGN KEY: --
  • 13. Database and Web Database System PT1081156 - Individual Assignment Page 13 3) DAYS_AVAILABLE CONSTRAINTS: PRIMARY KEY: Train_ID FOREIGN KEY: -- Train_ID 4) STATION CONSTRAINTS: PRIMARY KEY: Station_ID FOREIGN KEY:--
  • 14. Database and Web Database System PT1081156 - Individual Assignment Page 14 5) PASSENGER CONSTRAINTS: PRIMARY KEY: PNR FOREIGN KEY: Train_ID 6) PASSENGER_TICKET CONSTRAINTS: PRIMARY KEY: PNR FOREIGN KEY: Train_ID
  • 15. Database and Web Database System PT1081156 - Individual Assignment Page 15 7) TRAIN_STATUS CONSTRAINTS: PRIMARY KEY: Train_ID, Available_Date FOREIGN KEY: Train_ID 8) ROUTE CONSTRAINTS: PRIMARY KEY: Train_ID, Stop_number FOREIGN KEY: Train_ID
  • 16. Database and Web Database System PT1081156 - Individual Assignment Page 16 9) ROUTE_HAS_STATION CONSTRAINTS: PRIMARY KEY: Train_ID,Station_ID FOREIGN KEY: Station_ID 10) USER CONSTRAINTS: PRIMARY KEY: EmailID FOREIGN KEY:
  • 17. Database and Web Database System PT1081156 - Individual Assignment Page 17 11) ADMIN CONSTRAINTS: PRIMARY KEY: UserID FOREIGN KEY: 12) RESERVATION CONSTRAINTS: PRIMARY KEY: PNR,EmailID,Available_Date,PNR FOREIGN KEY:--
  • 18. Database and Web Database System PT1081156 - Individual Assignment Page 18 7.QUERIES 7.1 DDL_STATEMENTS 1) TRAIN create table Train (Train_ID int not null, Train_name varchar(50) not null, Train_type varchar(50) not null, Source_stn varchar(30) null, Destination_stn varchar(30) null, Source_ID varchar(8) null, Destination_ID varchar(8) null, primary key(Train_ID), foreign key(Source_ID) references Station(Station_ID) on update cascade on delete cascade, foreign key (Destination_ID) references Station(Station_ID) on update no action on delete no action) 2) TRAIN_CLASS create table Train_class (Train_ID int not null, Fare_Class1 int not null, Seat_Class1 int not null, Fare_Class2 int not null, Seat_Class2 int not null,Fare_Class3 int not null, Seat_Class3 int not null, primary key(Train_ID)) 3) DAYS_AVAILABLE Create table Days_Available(Train_ID int not null, Available_days varchar(20), primary key(Train_ID)) 4) STATION Create table Station(Staiton_ID int not null, Station_Name varchar(25), primary key(Station_ID) ) 5) PASSENGER create table Passenger ( PNR varchar(25) not null, Seat_number int not null, Passenger_name varchar(30) not null, Age int not null, Gender varchar(8) not null, Train_ID int not null,foreign key(Train_ID) references Train(Train_ID) on update cascade on delete cascade, primary
  • 19. Database and Web Database System PT1081156 - Individual Assignment Page 19 key(PNR, Seat_number) ) 6) PASSENGER_TICKET create table Passenger_ticket ( PNR varchar(25) not null, Source_ID varchar(8) not null, Destination_ID varchar(8) not null, Class_type varchar(50) not null, Reservation_status varchar(25) not null, Train_ID int not null,foreign key(Train_ID) references Train(Train_ID) on update cascade on delete cascade, primary key(PNR) ) 7) RESERVATION create table Reservation (Train_ID int not null, Available_Date varchar(20) not null, EmailID varchar(30) not null, PNR varchar(20) not null, Reservation_Date text not null, Reservation_Status varchar(20) null, foreign key(Train_ID,Available_Date) references Train_status1 (Train_ID,Available_Date) on update cascade on delete cascade, foreign key(EmailID) references User_table(EmailID) on update cascade on delete cascade, primary key(Train_ID,Available_Date,EmailID,PNR) ) 8) TRAIN_STATUS create table Train_status3 (Train_ID int not null, Available_Date varchar(20) not null, Booked_seats3 int null, Waiting_seats3 int null, Available_seats3 int null, primary key(Train_ID,Available_Date), foreign key(Train_ID) references Train(Train_ID) on update cascade on delete cascade) 9) ROUTE create table Route (Train_ID int not null, Stop_number int not null, Station_ID varchar(8) not null , Arrival_time text not null, Departure_time text not null, Source_distance int not null, primary key(Train_ID,Stop_number), foreign key(Train_ID) references Train(Train_ID) on update cascade on delete cascade)
  • 20. Database and Web Database System PT1081156 - Individual Assignment Page 20 10) ROUTE_HAS_STATION create table Route_HAS_Station (Train_ID int not null,Station_ID varchar(20) not null, Stop_number int not null, primary key(Train_ID, Station_ID)) 11) USER Create table User_table ( EmailID varchar(30) not null, Password varchar(15) not null, FullName varchar(30) not null, Gender varchar(8) not null, Age int not null, Mobile varchar(14) not null, City varchar(20) not null, State varchar(25) not null, Security_question varchar(40) not null, Security_answer varchar(20) not null ) 12) ADMIN create table Admin_table (User_ID varchar(20) not null, Password varchar(15) not null, primary key(User_ID)) 7.2 DML STATEMENTS INSERT STATEMENTS Adding a new Station – This step is used to add a new station to the station table where the admin provides the station name and the station id by which it will be recognized. insert into Station values('" + txt_id.Text + "','" + txt_name.Text + "' ) Adding a Route – Data is inserted into the Route table. Table route receive entries of train id, stop number, station id, arrival time, departure time and the source distance. insert into Route values('" + txt_trainid2.Text + "','" + txt_stopno.Text + "','"+txt_stnid.Text +"','" + txt_arrival.Text + "','" + txt_departure.Text + "','" + txt_distance.Text + "') UPDATE STATEMENTS
  • 21. Database and Web Database System PT1081156 - Individual Assignment Page 21 Update Station update Station set Station_ID='" + txt_id.Text + "' where Station_name ='" + txt_name.Text + "' Update Train update Train set Train_name= '" + txt_trainname.Text + "', Train_type='" + ddl_type.SelectedItem + "',Source_stn='" + ddl_source.SelectedItem + "', Destination_stn='" + ddl_dest.SelectedItem + "' where Train_ID='"+txt_trainid.Text +"' RESERVATION QUERIES RESERVATION Read data from Station table and get Source Station ID SqlCommand cmd = new SqlCommand("Select * from Station where Station_name ='" + ddl_source.SelectedItem.ToString() + "'", con1); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { txt_sid.Text = dr["Station_ID"].ToString(); } dr.Close(); Read data from Station table and get Destination Station ID SqlCommand cmd = new SqlCommand("Select * from Station where Station_name ='" + ddl_dest.SelectedItem.ToString() + "'", con1); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { txt_did.Text = dr["Station_ID"].ToString(); } dr.Close();
  • 22. Database and Web Database System PT1081156 - Individual Assignment Page 22 Get list of trains available on a particular date between a pair of stations Select Route.Train_ID, Train.Train_name ,Train_status.Available_Date FROM Route INNER JOIN Train ON Route.Train_ID=Train.Train_ID INNER JOIN Train_status ON Train.Train_ID=Train_status.Train_ID WHERE (Route.Station_ID IN (SELECT Source.Station_ID FROM Route AS Source INNER JOIN Route AS Destination ON Source.Train_ID = Destination.Train_ID WHERE (Source.Stop_number - Destination.Stop_number < 0) AND (Source.Station_ID = @Source) AND (Destination.Station_ID = @Dest))) AND (Train_status.Available_Date = @Available_Date) Get seat status from table Train_status and display it when user selects the class from dopdownlist provided SqlCommand cmd = new SqlCommand("Select * from Train_status where Train_ID ='" + lbl_id.Text.ToString() + "'and Available_Date='" + txt_date.Text + "'", con1); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { lbl_seats.Text = dr["Available_seats1"].ToString(); Label7.Text = "Total available seats in "+lbl_class.Text +" are : "; lbl_msg.Text = "Total Seats already booked: "; lbl_booked.Text = dr["Booked_seats1"].ToString(); } dr.Close(); Calculate Fare form the Journey distance from the selected source and destination stations SqlCommand K = new SqlCommand("Select * from Route where Train_ID ='" + lbl_id.Text.ToString() + "' and Station_ID='" + txt_sid.Text + "'", kon); SqlDataReader dr2 = K.ExecuteReader(); while (dr2.Read()) { distance1.Text = dr2["Source_distance"].ToString(); } dr2.Close(); SqlCommand Kk = new SqlCommand("Select * from Route where Train_ID ='" + lbl_id.Text.ToString() + "' and Station_ID='" + txt_did.Text + "'", kon); SqlDataReader dr3 = Kk.ExecuteReader();
  • 23. Database and Web Database System PT1081156 - Individual Assignment Page 23 while (dr3.Read()) { distance2.Text = dr3["Source_distance"].ToString(); } dr3.Close(); int distance = (Convert.ToInt32(distance2.Text) - Convert.ToInt32(distance1.Text)); SqlCommand cmd = new SqlCommand("Select * from Train_class where Train_ID ='" + lbl_id.Text.ToString() + "'", con1); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { lbl_X.Text = dr["Fare_Class1"].ToString(); } int Y = Convert.ToInt32(lbl_X.Text); int fare = Y * Convert.ToInt32(ddl_seats.Text)*distance ; After Fare calculation, add passengers details to successfully complete the reservation process int a = Convert.ToInt32(lbl_seats.Text); int booked = Convert.ToInt32(lbl_booked.Text); SqlCommand cmd = new SqlCommand("insert into Passenger values('" + pnr + "','" + a + "','" + txt_pname1.Text + "','" + txt_age1.Text + "','" + ddl_gender1.SelectedItem + "','" + lbl_id.Text + "','" + lbl_email.Text + "')", conn); cmd.ExecuteNonQuery(); CANCELLATION QUERIES CANCELLATION When user cancels a ticket, the PNR status is set as CANCELLED update Passenger_ticket set Reservation_status = 'CANCELLED' where PNR="+txt_PNR.Text +"" With the cancellation of one ticked, available seats in Train_status table for that specific train should increase and booked seats should decrease by 1 update train_status set Available_seats1=Available_seats1+1 and Booked_seats1= Booked_seats1-1 where Train_ID=’”+lbl_id.Text+”’ and Available_Date=’”+lbl_date.Text+”’
  • 24. Database and Web Database System PT1081156 - Individual Assignment Page 24 8.FORM DESIGN 1) NEW REGISTRATION – USER DESCRIPTION: Any user coming to this page can register to the website by providing required details. The details being provided should not violate the validation rules otherwise registration will not be allowed. 2) LOGIN PAGE – ADMIN, USER DESCRIPTION: Registered users login to the website by using a specific EmailID and password. This will redirect the user to a different view level where the user will be availed various services like reservation, cancellation, etc.
  • 25. Database and Web Database System PT1081156 - Individual Assignment Page 25 3) ADD TRAIN DESCRIPTION: Admin of this website can add new trains to the database which will be further allowed for reservations. Train will be assigned a Train ID which should be unique and then a train name will also be assigned to the train for its identification. 4) ADD STATION DESCRIPTION: The admin is privileged to add and update new stations and station IDs to the system’s database.
  • 26. Database and Web Database System PT1081156 - Individual Assignment Page 26 5) ADD ROUTE DESCRIPTION: Already added trains require a route to be defined which it has to follow. The admin can use this page to add new route to the train where he/she has to add station ids and stop numbers along with arrival and departure times. 6) TRAIN STATUS DESCRIPTION: This page can be used to see the total available seats, booked seats and waiting seats in particular classes of a train. The train IDs is available in the dropdown list given.
  • 27. Database and Web Database System PT1081156 - Individual Assignment Page 27 7) MANAGE PROFILES DESCRIPTION: Admin can view the details of registered users and can also update and delete their accounts. Users whose account will be deleted won’t be able to use the reservation/ cancellation services of the site. 8) MANAGE TRAIN DESCRIPTION: Admin can view and update train details that have been added to the database of this system. The admin can find trains either by providing train id or train name.
  • 28. Database and Web Database System PT1081156 - Individual Assignment Page 28 9) CHECK PNR DESCRIPTION: Users who have reserved seats in any of the trains can enter the PNR number provided to them and can see the status of their ticket whether it is confirm, is cancelled or is queued in the waiting slot. 10) SEAT AVAILABILITY DESCRIPTION: This is used to view the available seats in a particular class of a train. User can enter the source and destination station name and the date for which they want to see the availability of seats.
  • 29. Database and Web Database System PT1081156 - Individual Assignment Page 29 11) VIEW SCHEDULE DESCRIPTION: Users can search and view train schedule and other details by proving the train number or the train name. The user will be shown the train details like arrival departure timings along with the route it will follow to reach to the destination station.
  • 30. Database and Web Database System PT1081156 - Individual Assignment Page 30 9.REPORTS 1) REPORT: TRAINS Description: The report TRAINS is used to show the list of Trains added by the admin to the database. This consists of the train id, train name, train type, source station name, and destination station name. This report can be downloaded in either of .pdf form or .docs form or as an excel sheet. Admin needs to see the detailed list of the trains like the train name, its source station and the destination station. The report also shows the type of train it is i.e., whether it is an express train or super fast or Rajdhani etc. This report will help in the management of trains to the admin.
  • 31. Database and Web Database System PT1081156 - Individual Assignment Page 31 2) REPORT: TRAIN ROUTE Description: The report TRAIN ROUTE displays details of the route that trains of this website will follow. It consists of the train id, station id where the train will stop, stop number, arrival time at the stop, departure time from the stop and the distance of the stop from the source station. When the user(admin) will want to see the the detailed list of trains along with its stop stations and its timings at all its stops from source to destination, this report will be helpful so that by viewing this report, any required changes/modifications can easily be made to the database.
  • 32. Database and Web Database System PT1081156 - Individual Assignment Page 32 10. TOOLBAR A toolbar has been provided in the user’s view level which consists of icons like Home, Train, and Ticket which serves as a link to the respective pages. The Home icon if clicked, redirects the user to the Home page of the user and similarly the Power button icon allows user a proper logout. This icon depicts the Home. On click of this, user is redirected to its homepage. This is the Schedule icon which takes the user to the “Check Schedule” page This is the Ticket icon on click of which takes the user to the “Check Schedule” page where the user will be able to reserve 1 or more seats in any particular train. The train icon redirects the user to the search train page which allows user to search different trains by entering the train id or the train name or even by entering any route station. The user can logout of the website by clicking this icon.
  • 33. Database and Web Database System PT1081156 - Individual Assignment Page 33 11. REFERENCES AND CITATION 1) SQL JOINS w3cschoolsadmin. (2013). SQL INNER JOIN. Available: http://www.w3schools.com/sql/sql_join_inner.asp. Last accessed 24th April 2013. 2) SQL LEFT JOIN w3cschoolsadmin. (2013). SQL LEFT JOIN. Available: http://www.w3schools.com/sql/sql_left_inner.asp. Last accessed 21st April 2013. 3) SQL UPDATE w3cschoolsadmin. (2013). SQL UPDATE. Available: http://www.w3schools.com/sql/sql_update.asp. Last accessed 15th April 2013. 4) INSERT STATEMENTS IN SQL BY C# marc. (2012). write insert query in c#. Available: http://stackoverflow.com/questions/9954900/how-to-write-insert-query-in-c. Last accessed 21st April 2013. 5) GRIDVIEW DATABINDING Msoft. (2013). GridView.DataBind Method. Available: http://msdn.microsoft.com/en-IN/library/fkx0cy6d.aspx. Last accessed 12th April 2013. 6) FOREGIN KEY CONSTRAINT w3cschoolsadmin. (2013). SQL FOREIGN KEY Constraint. Available: http://www.w3schools.com/sql/sql_foreignkey.asp. Last accessed 18th April 2013. 7) Referred to www.indianrail.gov.in/ and www.irctc.co.in .
  • 34. Database and Web Database System PT1081156 - Individual Assignment Page 34