0% found this document useful (0 votes)
10 views2 pages

CREATE DATABASE Railway - Reservation

Uploaded by

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

CREATE DATABASE Railway - Reservation

Uploaded by

Abhishek nair
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

CREATE DATABASE railway_reservation;

USE railway_reservation;

CREATE TABLE trains (


train_id INT PRIMARY KEY,
train_name VARCHAR(100),
source VARCHAR(50),
destination VARCHAR(50),
departure_time DATETIME,
arrival_time DATETIME
);

CREATE TABLE coaches (


coach_id INT AUTO_INCREMENT PRIMARY KEY,
train_id INT,
coach_type VARCHAR(20),
total_seats INT,
available_seats INT,
FOREIGN KEY (train_id) REFERENCES trains(train_id)
);

CREATE TABLE reservations (


reservation_id INT AUTO_INCREMENT PRIMARY KEY,
user_name VARCHAR(100),
train_id INT,
coach_type VARCHAR(20),
seat_count INT,
departure_city VARCHAR(50),
arrival_city VARCHAR(50),
status VARCHAR(20),
FOREIGN KEY (train_id) REFERENCES trains(train_id)
);

-- Insert sample data


INSERT INTO trains (train_id, train_name, source, destination, departure_time,
arrival_time) VALUES
(110256, 'Rajdhani Express', 'Ankleshwar', 'Delhi', '2025-04-20 06:00:00', '2025-
04-22 15:00:00'),
(652319, 'Satabdhi Express', 'Ankleshwar', 'Delhi', '2025-04-20 09:00:00', '2025-
04-22 18:00:00'),
(259032, 'Vandehbharat', 'Kochi', 'Shimla', '2025-05-01 08:00:00', '2024-05-4
17:30:00'),
(782195, 'Malabar Express', 'Kochi', 'Shimla', '2025-05-01 04:00:00', '2024-05-4
13:30:00'),
(378149, 'Duronto Express', 'Lucknow', 'Chennai ', '2025-01-20 10:00:00', '2025-01-
22 19:00:00'),
(105693, 'Rajdhani Express', 'Lucknow', 'Chennai ', '2025-01-20 14:00:00', '2025-
01-22 23:00:00'),
(411905, 'Omkar Express', 'jodhpur ', 'Bangalore', '2025-02-27 05:30:00', '2025-03-
02 09:30:00');
(349907, 'KSR bengluru double Decker', 'jodhpur ', 'Bangalore', '2025-02-27
03:30:00', '2025-03-02 07:30:00');

INSERT INTO coaches (train_id, coach_type, total_seats, available_seats) VALUES


(110256, 'Sleeper', 150, 50),
(110256, 'AC', 100, 20),
(652319, 'Sleeper', 162, 34),
(652319, 'AC', 50, 36);
(259032, 'Sleeper', 180, 70),
(259032, 'AC', 120, 30),
(782195, 'Sleeper', 130, 60),
(782195, 'AC', 100, 40);
(378149, 'Sleeper', 200, 90),
(378149, 'AC', 150, 50),
(105693, 'Sleeper', 190, 70),
(105693, 'AC', 130, 60);
(411905, 'Sleeper', 180, 60),
(411905, 'AC', 130, 40),
(349907, 'Sleeper', 120, 40),
(349907, 'AC', 110, 35);

DROP TABLE trains;


DROP TABLE coaches;
DROP TABLE reservations;

CREATE TABLE users (


user_un INT AUTO_INCREMENT PRIMARY KEY,
user_ID VARCHAR(50) UNIQUE NOT NULL,
password VARCHAR(255) NOT NULL
);

-- Insert a sample user (password should be hashed in a real application)


INSERT INTO users (user_ID, password) VALUES ('Admin', 'Admin_6789');

You might also like