0% found this document useful (0 votes)
55 views8 pages

18bce0009 Dbms Da

This document contains the lab assignment details of a student named Mahendra Someneni. The assignment involves redesigning the database of Indian Railway Catering and Tourism Corporation (IRCTC). Several SQL queries are written to retrieve information from tables like Train, Ticket, Passenger etc. High-level operations like adding a new column, updating values, and formatting retrieval values are demonstrated.

Uploaded by

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

18bce0009 Dbms Da

This document contains the lab assignment details of a student named Mahendra Someneni. The assignment involves redesigning the database of Indian Railway Catering and Tourism Corporation (IRCTC). Several SQL queries are written to retrieve information from tables like Train, Ticket, Passenger etc. High-level operations like adding a new column, updating values, and formatting retrieval values are demonstrated.

Uploaded by

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

DATABASE MANAGEMENT SYSTEMS:

CSE-2004

Lab Assignment-2

Name: MAHENDRA SOMENENI

Reg.no:18BCE0009

Slot: L53+L54

Faculty name: Dilip Kumar Choubey

Railway Reservation System -(Redesigning IRCTC database)


Train(train Number, name, source, destination, start_time, reach_time,
traveltime, distance, class, days, type)
Ticket( PNRNo,Transaction_id, from_station, To_station,
date_of_journey, class, date_of_booking, total_ticket_fare,train number)
Passenger(PNR No, Serial no, Name, Age, Reservation_status)
Train_Route(Train_No, route_no, station_code, name, arrival_time,
depart_time, distance,day)
Train_Ticket_fare(Train_No, class, base_fare, reservation_charge,
superfast_charge, other_charge, tatkal_charge, service_tax)
1.Find the passengers whose date of journey is one month from today.
SQL> select PNRNO from Ticket where
to_date(date_of_journey,'dd/mm/yyyy')=add_months('08-AUG-2018',1);

no rows selected

2. Print the train names in upper case.


SQL> select upper(name) from Train;

UPPER(NAME)
------------------------------
SATHABDHI EXPRESS
ANDAMAN EXPRESS
MANDOR EXPRESS
G T EXPRESS
TAMIL NADU EXPRESS

3. Print the passenger names with left padding character.

SQL> select lpad(name,20,'@') from Passenger_details;

LPAD(NAME,20,'@')
--------------------
@@@@@@@MAHENDRA
@@@@@@@@@DHONI
@@@@@@@@@SURESH
@@@@@@@@@VIRAT
@@@@@@@@AKSHAY

4.Print the station codes replacing K with M.

SQL> select replace(station_code,'K','M') from Train_Route;

REPLACE(STATION_CODE
--------------------
JP
DEC
AGC
GWL
BPL

5. Translate all the LC in class column (Train_fare) to POT and display.


SQL> select translate(class,'LC','POT') from Train_ticket_fare;

TRANSLATE(CLASS,'LC','POT')
------------------------------
AO OHAIR OAR
AO OHAIR OAR
sleeper
sleeper
sleeper

6.Display the fare details of all trains, if any value is ZERO, print as NULL value.
SQL> select *from Train_Ticket_fare;

TRAIN_NUMBER CLASS BASE_FARE RESERVATION_CHARGE


------------ ------------------------------ ---------- ------------------
SUPERFAST_CHARGE OTHER_CHARGE TATKAL_CHARGE SERVICE_TAX
---------------- ------------ ------------- ----------
-
12621 sleeper 730 20
30 230
12015 AC CHAIR CAR 582 40
45 80 184
12050 AC CHAIR CAR 462 40
45 175 146 27

TRAIN_NUMBER CLASS BASE_FARE RESERVATION_CHARGE


------------ ------------------------------ ---------- ------------------
SUPERFAST_CHARGE OTHER_CHARGE TATKAL_CHARGE SERVICE_TAX
---------------- ------------ ------------- -----------
12461 sleeper 320 20
30 101
12616 sleeper 730 20
30 230

7.Display the pnrno and transaction id, if transaction id is null, print 'not generated'.

SQL> select pnrno,nvl(transactionid,'not generated') from ticket;

PNRNO NVL(TRANSACTIONID,'NOTGENERATE
---------- ------------------------------
2334567890 VADE0B248930
2334567880 VADE0B248920
2334567850 VADE0B248910
2334567892 VADE0B248910
2334567891 VADE0B248931

8. Print the date_of_journey in the format '27th November 2010'.


SQL> select to_char(to_date(date_of_journey,'DD/mm/yyyy'),'ddth month yyyy') from Ticket;

TO_CHAR(TO_DATE(DAT
-------------------
09th august 2018
10th august 2018
11th august 2018
06th august 2018
06th august 2018

9. Find the maximum fare (total fare).


SQL> select max(TOTAL_TICKET_FARE) from ticket;

MAX(TOTAL_TICKET_FARE)
----------------------
780
10. Find the average age of passengers in one
ticket. SQL> select avg(age) from Passenger_details;

AVG(AGE)
----------
22

11.Find the maximum length of station name available in the database.


SQL> select max(length(name)) from Train_route;

MAX(LENGTH(NAME))
-----------------
11

12.Print the fare amount of the passengers as rounded value.


SQL> select round(total_ticket_fare) from ticket;

ROUND(TOTAL_TICKET_FARE)
------------------------
700
665
370
780
780

13. Add the column halt time to train route.


SQL> alter table Train_route add Halt_time_min number(3);

Table altered.

14. Update values to it from arrival time and depart time.


SQL> update Train_route set Halt_time_min=10 where train_number=12461;

1 row updated.

SQL> update Train_route set Halt_time_min=2 where train_number=12015;

1 row updated.

SQL> update Train_route set Halt_time_min=3 where train_number=12621;

1 row updated.
SQL> update Train_route set Halt_time_min=2 where train_number=12050;

1 row updated.

SQL> update Train_route set Halt_time_min=5 where train_number=12616;

1 row updated.

High Level:

15. Update values to arrival time and depart time using conversion functions.

16. Display the arrival time, depart time in the format HH:MI (24 hours and minutes).

SQL> select arrival_time,depart_time from Train_route;

ARRIVAL_TI DEPART_TIM

---------- ----------

02:35 02:45

06:33 06:35

01:00 01:03

11:16 11:18

05:20 05:25

*THE END*

You might also like