Assignment 1
Assignment 1
Assignment 1
Registration id –
The problem statement-
Sample Database: Southern Railways
I. Create tables for the following requirements
Train:
Number, name, source, destination, start_time, reach_time
Passenger:
PNR No, Serial no., Name, Sex, Address, Age, Date of
Journey,
Status, kind of seat, seat no, Train number
II. Insert necessary values into the tables.
III. Constraints
1. Add a primary key constraint to train, Passenger.
2. Add a referential key constraint to passenger.
3. Add a check constraint to insert source and destination
in 3 letters
4. Add a check constraint to enter a valid kind of seat
while a
Passenger record is added for a train.
IV. Write queries for the following:
1. List all train details.
2. List all passenger details.
3. Give a list of trains in ascending order of number.
4. Find out the number of passengers booked for a
particular
Train.
5. List the number of waiting lists in a train “x”.
6. List the number of female passengers who have booked
for
trains (train name wise).
select length(source_t) as ST
from Train;
select length(source_t) as ST
from Train
check(ST = 3);