0% found this document useful (0 votes)
4 views40 pages

Railway Reservation System Project 2024

Uploaded by

akshansh0402
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views40 pages

Railway Reservation System Project 2024

Uploaded by

akshansh0402
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

VIDYASTHALI PUBLIC SCHOOL, JAIPUR

INFORMATIC
PRACTICES
2024-2025

Railway Reservation
Management System
CERTIFICATE
This is to certify that Yuvika Pandey of
class 12, Commerce has successfully
Submitted by :the project titled
completed “Railway
Submitted to :
Reservation
Yuvika Pandey Management System” in
Mrs. Vinita Jangid
partial fulfillment of the requirements of
Class XII Commerce
the CBSE curriculum for Information
Practices.
This project has been completed under
the guidance of Mrs Vinita Jangid for
the academic year 2024-2025. It
demonstrates the application of
programming and database
management skills, using Python and
MySQL, to develop a comprehensive
railway reservation management
[Link] project is an original piece of
work by Yuvika Pandey and reflects a
clear understanding of the subject
matter. It meets the required standards
and objectives set forth by the CBSE
board.
1 | Page
Mrs Vinita Jangid
Information Practices Teacher
Vidyasthali Public School
ACKNOWLEDGEMENT
I would like to express my sincere
gratitude to everyone who contributed
to the successful completion of my
project on Railway Reservation
Management.
I am deeply thankful to my Information
Practices teacher, Mrs Vinita Jangid for
providing me with invaluable guidance,
encouragement, and support throughout
the project. Their insights and
constructive feedback were instrumental
in helping me understand the intricacies
of programming and database
management, which allowed me to
develop a comprehensive railway
reservation system.
Lastly, I am grateful to the CBSE board
for structuring the curriculum in a way
2 | Page
that encourages hands-on learning and
application of theoretical knowledge
through projects like this, which have
significantly enhanced my practical skills
and understanding of subject.

Yuvika Pandey
Class 12

3 | Page
TABLE OF CONTENT

1. Certificate
2. Acknowlegement
3. User defined functions
4. Introduction
5. Project synopsis
6. Uses of railway
reservation management
7. Scope of railway
reservation management
8. Need for computerization
9. Overview of project
10. Source code
11.

4 | Page
USER DEFINED
FUNCTIONS:
A function is a block of code
which only runs when it is
called. You can pass data,
known as parameters, into a
function. A function can return
data as a result.

1. Creating a Function
In Python a function is defined using the
def keyword:
eg: defmy_function(): print("Hello you
are creating a function")

5 | Page
2. Calling a Function

To call a function, use the function name


followed by parenthesis:
eg: defmy_function(): print("Hello you
are creating a function") my_function()

3. Arguments

Information can be passed into function.


as arguments. Arguments are specified
after the function name,inside the
parenthesis. You can add as
many arguments as you want, just
seperate them with a comma.
The following example has a function
with one argument (fname). When the
function is called, we pass along a first
name, which is used inside the function
to print the full name:

6 | Page
Example:
defmy_function(fname):
print(fname +
“Agrawal”)
my_function("Anjali")
my_function("Aashi")
my_function("Raj")

Parameters or Arguments?

A parameter is the variable listed inside


the parentheses in the function
definition. An argument is the value that
are sent to the function when it is called.
Number of Arguments By default, a
function must be called with the correct
number of arguments.
Meaning that if your function expects 2
arguments, you have to call the function

7 | Page
with 2 arguments, not more, and not
less.
Example:
This function expects 2 arguments and
gets 2 arguments.
defmy_function(fname, Iname):
print(fname + "'" + Iname)
my_function("Anjali", "Agrawal")

4. Return Values

To let a function return a value, use


return
the statement:
Example:
defmy_function(a):
return 5* a
print(my_function(3))
print(my_function(5))

8 | Page
print(my_function(9))

5. The pass
Statement
Function definitions cannot be empty,
but if you for some reason have a
function definition with no content, put
in the pass statement to avoid getting
an error.
Example: defmy_function():
pass
function and its output is processed by a
second function.

7. COMMENTING
FUNCTION

9 | Page
Function Header comments are used
to describe the purpose of a function.
Every function must have a separate
header comment. Function headers
serve to describe the algorithm which
the function implements without forcing
the reader to interpret code.

8. CASTING
Casting is a manufacturing process by
which a molten material such as metal
or plastic is introduced into a mould,
allowed to solidify within the mould,
and then ejected or broken out to make
a fabricated part.

INTRODUCTION
Python:

Python is a high-level, general-purpose


programming language. Its design
10 | Page
philosophy emphasizes code readability
with the use of significant indentation.
Python is dynamically-typed and
garbage- [Link] supports multiple
programming paradigms, including
structured (particularly procedural),
object-oriented and functional
[Link] is often described as a
batteries included" language due to its
comprehensive standard library.
It is a popular embedded programming
language used in Arduino, Raspberry Pi,
and others. This project aims to
familiarize beginners with some Python
libraries that can be implemented in
embedded projects as well. Python is
simple to start out with, fun, and easy to
learn.

Project Synopsis
The Railway Registration Management
System is a Python-based application
designed to streamline railway ticket
11 | Page
booking, user registration, and ticket
management.

The project integrates Python with


MySQL to securely store and manage
user and ticket data, leveraging the
MySQL Connector for efficient database
communication. It
provides essential features such as user
sign-up, login, ticket booking,
cancellation, and status checking,
creating a simple yet comprehensive
system for railway ticket management.

A unique feature of this project is its


custom ID management system, which
programmatically assigns unique IDs to
users and tickets, ensuring data
consistency and integrity. The
project demonstrates core concepts of
database-driven application
development, emphasizing ease of use,
data security, and robust functionality.

12 | Page
This system can serve as a foundational
prototype for larger, more complex
railway booking applications and is
designed to be expanded with additional
features, such as payment integration or
advanced search options, in future
iterations.

13 | Page
Uses of the Railway
Registration
Management System

[Link] Ticket Booking


Allows users to conveniently book
train tickets by entering details like
train number, journey date, and
travel class, making the booking
process fast and accessible.

[Link] Profile Management


Provides secure account creation and
login for users, maintaining their
travel information, booking history,

14 | Page
and personal details in a centralized
database

[Link] Ticket
Cancellation

Enables users to cancel bookings


easily, updating ticket records
accurately for proper record-
keeping and future reference.

[Link] Record and Status


Tracking

Facilitates easy access for users


to view current and past bookings,
along with each ticket's status,
15 | Page
helping them manage and review
their travel plans conveniently.

[Link] Management and


Consistency
Through a custom ID system and
relational database structure, the
project ensures data consistency
across users and tickets, preventing
data duplication or orphan records.

[Link] for Larger Systems


Serves as a prototype for
developing comprehensive railway
or travel management systems,
covering essential features like
user management, booking, and
cancellation, which can be scaled or
extended as needed.

16 | Page
This Railway Registration Management
System provides an educational
foundation for understanding the
integration of Python with MySQL
databases, supporting the development
of more complex database applications
in railway or travel-related services.

Scope of the Railway


Registration Management
System

The Railway Registration Management


System project aims to create a
streamlined platform for managing
railway ticket bookings and user profiles
with key functionalities. The scope of
this project includes the design,
development, and deployment of a
Python-based application that interacts
with a MySQL database to handle
essential railway registration tasks. The
system's primary focus is on simplifying
the booking and ticket management
17 | Page
process, ensuring data consistency, and
providing a user-friendly interface for
both travelers and administrative
functions. The project scope includes the
following features and capabilities:

●User Registration and


Authentication: Secure sign-up
and login with profile data storage.
●Ticket Booking Functionality:
Simple interface for booking with
travel details.
●Ticket Management: Options for
cancellation, status checks, and
history tracking.

●Data Integrity and Consistency:


Unique ID generation and relational
data management.

●Error Handling and User


Guidance: User feedback on errors
for smoother operation.
18 | Page
●Future Scalability: Flexible design
for adding features like payments or
multi-user support.

●Educational Purpose:
Demonstrates Python-MySQL
integration and database
management basics.

NEED FOR
COMPUTERISATION

No one can easily plan the journey


comfortably as the process is efficient
and fast with being easy to access.
Reservations can be made through the

19 | Page
Indian railways site or at the ample
reservation centers all over the country.

Also now there are authorized agencies


which provide reservation facility on
behalf of India railways and without
waiting in long line one can easily book a
ticket. The booking is done through an E-
Ticket issue which has a PNR number of
which one has to take a print and just
have to show at the station.

It not only provides reservation but


cancellation can also be done through
this system at ease and one can use a
credit card to complete the process. This
being a big step in terms of
improvement in the railway system it is
widely accepted across the country.

20 | Page
OVERVIEW OF THE
PROGRAM:

This is a project based on train reservation.


The program helps us to enter,
display or alter the details of different trains.
Moreover & most importantly the
program helps us to reserve or cancel a
train ticket.

The program also helps us to know the


present status of a reserved ticket,
i.e. whether the ticket is confirmed or not.
It includes various function programs to do
the above mentioned tasks.
Data file handling has been effectively used
in the program.
The database is a collection of interrelated
data to serve multiple
applications. That is database programs
create files of information. So we
21 | Page
see that files are worked with most, inside
the program.

DBMS

The software required for the management of


data is called as DBMS. It
has3 models
• Relation model
• Hierarchical model
• Network model

RELATIONAL MODEL:
It’s based on the concept on relation.
Relation is the
table that consists of rows and columns. The
rows of the table are called
tuple and the columns of the table are called
attribute. Numbers of rows in
the table is called as cardinality. Number of
columns in the table is called
as degree.

22 | Page
HIERARCHICAL MODEL:
In this type of model, we have multiple
record for each record. A particular record
has one parent record. No chide record
can exist without parent record. In this, the
records are organized in tree like structure

NETWORK MODEL:
In this, the data is represented by collection
of records and relationship is represented by
link or association.

CHARACTERISTICS OF DBMS: -
• It reduces the redundancy
• Reduction of data in inconsistency
• Data sharing
• Data standardization
23 | Page
DIFFERENT TYPES OF FILES:

-BASED ON ACCESS:-

• Sequential file
• Serial file
• Random (direct access) file

BASED ON STORAGE:-

• Text file
• Binary File

DBMS: MySQL
Host : localhost
User: root

24 | Page
Pass: root

25 | Page
SOURCE CODE
MAIN CODE
#python program to illustrate

import [Link]
from getpass import getpass

# Database connection setup


conn = [Link](
host="localhost",
user="root",
password="root",
database="railway_reservation"
)
cursor = [Link]()

# Helper functions
def get_unique_id(table, column):

26 | Page
[Link](f"SELECT {column} FROM
{table}")
existing_ids = {int(row[0]) for row in
[Link]()}
new_id = 1
while new_id in existing_ids:
new_id += 1
return str(new_id).zfill(6)

# Sign up function
def sign_up():
username = input("Enter username: ")
password = getpass("Enter password: ")

user_id = get_unique_id("users", "user_id")


[Link]("INSERT INTO users
(user_id, username, password) VALUES (%s,
%s, %s)", (user_id, username, password))
[Link]()
print("User signed up successfully!")

# Sign in function

27 | Page
def sign_in():
username = input("Enter username: ")
password = getpass("Enter password: ")

[Link]("SELECT user_id FROM


users WHERE username=%s AND password=
%s", (username, password))
user = [Link]()
if user:
print("Login successful!")
return user[0]
else:
print("Invalid credentials.")
return None

# Book ticket function


def book_ticket(user_id):
train = input("Enter train name: ")
date_of_journey = input("Enter date of
journey (YYYY-MM-DD): ")
source = input("Enter source station: ")

28 | Page
destination = input("Enter destination
station: ")

ticket_id = get_unique_id("tickets",
"ticket_id")
[Link]("INSERT INTO tickets
(ticket_id, user_id, train, date_of_journey,
source, destination) VALUES (%s, %s, %s, %s,
%s, %s)",
(ticket_id, user_id, train,
date_of_journey, source, destination))
[Link]()
print(f"Ticket booked successfully! Your
Ticket ID is {ticket_id}.")

# Check ticket function


def check_ticket(user_id):
ticket_id = input("Enter Ticket ID: ")
[Link]("SELECT * FROM tickets
WHERE ticket_id=%s AND user_id=%s",
(ticket_id, user_id))
ticket = [Link]()
if ticket:

29 | Page
print(f"Ticket ID: {ticket[0]}, Train:
{ticket[2]}, Date: {ticket[3]}, Source:
{ticket[4]}, Destination: {ticket[5]}")
else:
print("No ticket found with the given
ID.")

# Delete ticket function


def delete_ticket(user_id):
ticket_id = input("Enter Ticket ID to delete:
")
[Link]("SELECT * FROM tickets
WHERE ticket_id=%s AND user_id=%s",
(ticket_id, user_id))
ticket = [Link]()
if ticket:
[Link]("DELETE FROM tickets
WHERE ticket_id=%s", (ticket_id,))
[Link]()
print("Ticket deleted successfully!")
else:
print("No ticket found with the given
ID.")

30 | Page
# Main program loop
def main():
print("Welcome to Railway Reservation
Management System!")
while True:
print("\n1. Sign Up\n2. Sign In\n3. Exit")
choice = input("Enter your choice: ")

if choice == '1':
sign_up()
elif choice == '2':
user_id = sign_in()
if user_id:
while True:
print("\n1. Book Ticket\n2. Check
Ticket\n3. Delete Ticket\n4. Logout")
action = input("Enter your
choice: ")
if action == '1':
book_ticket(user_id)
elif action == '2':
31 | Page
check_ticket(user_id)
elif action == '3':
delete_ticket(user_id)
elif action == '4':
print("Logging out...")
break
else:
print("Invalid choice. Please
try again.")
elif choice == '3':
print("Exiting system. Goodbye!")
break
else:
print("Invalid choice. Please try
again.")

# Close the database connection


[Link]()
[Link]()

if __name__ == "__main__":
main()
32 | Page
TABLES CODE
#MySQL CLC to illustrate

CREATE DATABASE railway_reservation;


USE railway_reservation;
CREATE TABLE users (
user_id VARCHAR(10) PRIMARY KEY,
username VARCHAR(50) UNIQUE NOT
NULL,
password VARCHAR(50) NOT NULL
33 | Page
);

CREATE TABLE tickets (


ticket_id VARCHAR(10) PRIMARY KEY,
user_id VARCHAR(10) NOT NULL,
train VARCHAR(50) NOT NULL,
date_of_journey DATE NOT NULL,
source VARCHAR(50) NOT NULL,
destination VARCHAR(50) NOT NULL,
FOREIGN KEY (user_id) REFERENCES
users(user_id)

34 | Page
OUTPUT
1. Sign Up

35 | Page
36 | Page
3. 2. Sign
Book In
Ticket

37 | Page
5. Delete Ticket

4. Check Ticket

38 | Page
Bibliography

● Information Practices class


6. XII
Log Sumita
Out Arora
● Websites :- [Link]
[Link]
[Link]
[Link]

7. Exit

39 | Page

You might also like