DBMS Lab Assesment 1: Name:-Yash Renwa Reg - No: - 19BIT0125

Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

DBMS Lab Assesment 1

Name:- Yash Renwa


Reg.No:- 19BIT0125.

1. 1. Create all the tables specified above. Make underlined


columns as primary key.(use number,

number(m,n), varchar(n), date, time, timestamp datatypes


appropriately) (Low Level)

Insert atleast 5 rows to each table. (Check www.irctc.co.in


website for actual data)

1. Use Interactive insertion for inserting rows to the table.

2. Use ADT(varray) for class and days column in Train table.

Solution:-

Create class, days, type which will be used in Train Table:-

Creating Tables:-

Data entering in tables:-

2) Solutions:-

1. Remove all the rows from Passenger table permanently.

2. Change the name of the Passenger table to


Passenger_Details.

3. List all train details.

4. List all passenger details.

Here data cannot be found because in above query we deleted


all data

5. Give a list of trains in ascending order of number.

6. List the senior citizen passenger details.

7. List the station names where code starts with 'M'.

8. List the train details within a range of numbers.

9. Change the superfast charge value in train fare as zero, if it is


null.

Here no value is null therefore:-

10. List the passenger names whose tickets are not confirmed.

11. List the base_fare of all AC coaches available in each train.

Find the ticket details where transaction id is not know:-

1. Use interactive update for updating the seat no for a particular


PNR NO

2. Find the train names that are from Chennai to Mumbai, but do
not have the source or destination in its name.

3. Find the train details that are on Thursday (Use the ADT
column created).

3) Create (Alter table to add constraint) the necessary foreign


keys by identifying the relationships in the table.

1. Add a suitable constraint to train table to always have train no


in the range 10001 to 99999.

2. Add a suitable constraint for the column of station name, so


that does not take duplicates.

The below error occured because many trains entered have


common source and destinations.

3. Change the data type of arrival time, depart time (date ->
timestamp or timestamp to date), and do the necessary process
for updating the table with new values.

4. Add a suitable constraint for the class column that it should


take values only as 1A,2A, 3A, SL, C.

5. Add a not null constraint for the column distance in train_route:

4) Use SQL PLUS functions to.

1. Find the passengers whose date of journey is one month from


today.

2. Print the train names in upper case.

3. Print the passenger names with left padding character.

4. Print the station codes replacing K with M.

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


display.

6. Display the fare details of all trains, if any value is ZERO, print
as NULL value.

7. Display the pnrno and transaction id, if transaction id is null,


print 'not generated'.

Here when making table trasactionid is set to notnull

Therefore the above query when given gives error

8. Print the date_of_jounrney in the format '27th November


2010'.

9. Find the maximum fare (total fare).

10. Find the average age of passengers in one ticket.

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


database.

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

13. Add the column halt time to train route.

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

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).

You might also like