DBMS Project
DBMS Project
Group no. – 48
Names: Sagnik Chattopadhyay(95)
Debdoot Biswas(96)
Subject: Database Management Systems
Laboratory
University of Engineering and Management (Kolkata)
1
INDEX:
Acknowledgement………………………………………… 3
ER Diagram ………………………………………………. 5
Conclusion ………………………………………………… 25
Remarks ………………………………………………….. 26
2
Acknowledgement
We, Sagnik Chattopadhyay and Debdoot Biswas, would firstly like to
thank our University for providing us with the infrastructure we used to
learn about the subject. Secondly, we would thank Sukalyan Goswami
sir, HOD of Computer Science Engineering department, UEM Kolkata.
Thirdly we would love to thank our concerned subject teachers Varsha
Poddar and Subarna Sen for providing us with the project idea and
necessary study material for the project.
3
Introduction:
Citizen Management System :
The Project ‘Citizen Card System’ gives us the information about the
citizen in any country. A Citizen has unique Id to find out the personal
information in each and every department or service wherever a citizen goes.
This information can be found out by the unique Id of the citizen.
4
ER- Diagram:
Pnr P_name
Password Age
U_id
Has Gender
Train
Has
T_id
Dept_d
Price
Arr_d
Ticket
Has
Route_id
Has Status_id
Route No_of_stop
Status
Dept_time
Start Wait_seat Booked_seat
Arr_time
Avail_seat
End
Has
Station
Station_name
Station_id
5
Sample SQL queries:
Creations:
Users
create table users( user_id varchar2(20) primary key,
password varchar2(20) not null
);
Passenger
create table passenger( pnr varchar(8) primary key,
p_name varchar2(30),
age number,
gender varchar(10),
seat_no number,
reserve_stat varchar2(10),
u_id varchar2(20) not null references users(user_id),
status_id varchar2(10) not null,
train_id varchar2(10) not null);
6
Train Status
create table train_stat( tstatus_id varchar2(10) primary key,
wait_seat number,
avail_seat number,
booked_seat number,
train_id varchar2(10) not null);
Train
create table train( train_id varchar2(10) primary key,
t_name varchar2(20) not null,
car_no number,
status_id varchar2(10) not null references
train_stat(tstatus_id));
Station
create table station( station_id varchar2(10) primary key,
station_name varchar2(30));
7
Route
8
Alterations:
1. SQL>alter table train drop column status_id;
( had conflicting foreign key)
SQL>alter table train add dept_date date;
SQL> alter table train add arr_date date;
9
Insertions:
Table: Users->
Table: Station->
10
Table: Train->
Table: Train_stat->
11
Table: Route->
12
Table: Passenger->
Table: Ticket->
13
Useful SQL queries related to the database:
14
4. Trains starting from Kolkata going to Delhi:
A. SQL> select train_id,to_st,t_name from route natural join train where
from_st = (select station_id from station where station_name = 'Kolkata')
and to_st = (select station_id from station where station_name =
'Delhi');
15
8. status of the trains going from Kolkata:
A. SQL> select train_id, wait_seat, avail_seat, booked_seat from route
natural join (train natural join train_stat) where from_st = (select
station_id from station where station_name = 'Kolkata');
16
12. No. of stops of trains connecting from Kolkata to Delhi:
A. SQL> select train_id, t_name, no_of_stops , from_st , to_st from train
natural join route where to_st = (select station_id from station where
station_name = 'Delhi') and from_st = (select station_id from station
where station_name = 'Kolkata') order by no_of_stops asc;
17
16. Passengers with ticket price more than 600 (inner join):
A. SQL> select passenger.pnr, p_name , train_id, ticket_id from
passenger, ticket where passenger.pnr = ticket.pnr and price >600 ;
18
20. Total seats in each trains:
A. SQL> select train_id, (wait_seat+avail_seat+booked_seat)
TOTAL_SEATS from train_stat;
19
24. Departure time of trains that leave from Kolkata:
A. SQL> select train_id,depart_time from train natural join route where
from_st = (select station_id from station where station_name = 'Kolkata');
26. Departure dates and times of trains leaving for Delhi from
Kolkata:
A. SQL> select train_id,dept_date, depart_time from train natural join
route where from_st = (select station_id from station where station_name
= 'Kolkata') and to_st = (select station_id from station where
station_name = 'Delhi');
20
27. Arrival time of trains in Delhi order by dates:
A. SQL> select train_id, arr_date, arr_time from route natural join train
where to_st = (select station_id from station where station_name = 'Delhi')
order by arr_date,arr_time;
29. Departure and arrival dates and times of all trains registered in
the database:
A. SQL> select train_id,dept_date, depart_time, arr_date, arr_time from
train natural join route order by dept_date;
21
30. Generate a ticket with necessary details:
A. SQL> select ticket_id, pnr, p_name, age, gender, train_id, compart_no,
seat_no, to_st, from_st, dept_date, depart_time, price from (passenger
natural join ticket) natural join (train natural join route) where p_name =
'Prithviraj';
22
Relational Model:
Passenger Ticket
User Pnr Ticket_id
P_name Pnr
U-id
Price
Age
Password
Gender
Seat_no
Reserve_stat
U_id
Train_id
Compart_no
Train
Train_stat
Train_id
Tstatus_id
T_name
Wait_seat
Car_no
Avail_seat
Dept_date
Booked_seat
Arr_date
Train_id
Route Station
Route_id Station_id
From_st
To_st Station_name
Depart_time
Arr_time
No_of_stops
Train_id
23
Future scope of the Project :
24
Conclusion:
Database Management and Data Handling is a big part of the IT industry.
Thus proper knowledge of SQL is important while working on databases
in order to avoid data redundancy and conflicts. Through this project, we
learned to avoid such data conflicts and implement the queries properly.
25
REMARKS:
26