0% found this document useful (0 votes)
123 views21 pages

Database Management System Lab Assignment-1

this document contains the data that is related to the sql operations in database management system.

Uploaded by

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

Database Management System Lab Assignment-1

this document contains the data that is related to the sql operations in database management system.

Uploaded by

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

DATABASE MANAGEMENT SYSTEM LAB ASSIGNMENT-1

NAME: GOPIKA. M SLOT: L1+L2


REG NO: 18MIS0379 FACULTY: KARTHIKEYAN. P
SQL>create table airport(airport_code number(10),name
varchar2(20),city varchar 2(20),state varchar2( 20))
Table created.
SQL>alter table airport add constraint airport_code primary
key(airport_code);

Table altered.

SQL>create table flight(flight_number number(20),air line


varchar2(20),weekdays varchar2(20));

Table created.

SQL>alter table f light add constraint flight_no primary key(flight_number) ;

Table altered.

SQL>create table flight_leg( flight_number number(20),leg_number


number( 20),scheduled_departure_time varchar2(20),department_airport_code
number( 20),arrival_airport_code number(10),scheduled_arrival_time varchar2(20));

Table created.

SQL>alter table f light_leg add constraint foreign_f l foreign key( flight_number)


refer ences flight(flight_number);

Table altered.
SQL>create table leg_instance( flight_number number(20),leg_number
number( 20),instance_date date,no_of_available_seats number(10),airplane_id
number( 20),departure_airport_code number(20),departure_time
varchar2(20),arrival_airport_code number(20),arrival_time varchar2(20));

Table created.

SQL>alter table leg_instance add constraint leg_pk


primary key(flight_number,leg_number,instance_date);

Table alt ered.

SQL>alter table leg_instance add constraint li_fk for eign key( flight_number,leg_number)
refer ences flight_leg(flight_number,leg_number) ;

Table alt ered.

SQL>create table fare(flight_number number(20) ,far e_code


number( 20),amount number(20),restrictions varchar2(20));

Table created.

SQL>alter table fare add constraint f_pk pr imar y


key(flight_number,fare_code);
Table altered.
SQL>alter table fare add constraint f_fk foreign key( flight_number)
refer ences flight(flight_number);
Table altered.

SQL>create table airplane_type(airplane_type_name


varchar2(20),max_seats number(20),company var char2(20));

Table created.

SQL>alter table airplane_type add constraint at_pk primary key(airplane_type_name);

Table altered.

SQL>create table can_land(airplane_type_name


varchar2(20),name varchar2(20),airport_code number(20));

Table created.

SQL>alter table can_land add constraint cl_pk


primary key(airplane_type_name,airport_code);

Table altered.

SQL>alter table can_land add constr aint cl_fk foreign key(airplane_type_name)


refer ences airplane_type(airplane_type_name) ;

Table altered.
SQL>create table airplane(airplane_id number (20),total_no_of_seats
number( 20),airplane_type varchar2( 20));

Table created.

SQL>alter table airplane add constraint a_pk primary key(air plane_id);

Table alt ered


.

SQL>create table seat_reservation( flight_number number(20),leg_number


number( 20),reservation_date date,seat_number number( 20),customer_name
varchar2(20),custome_phone number(10));

Table created.

SQL>alter table seat_reservation rename column r eservation_date to instance_date;

Table alt ered.

SQL>alter table seat_reservation add constraint sr_fk


foreignkey(leg_number,flight_number,instance_date)
refer ences
leg_instance(leg_number,flight_number,instance_date);

Table alt ered.


INSERTING VALUES TO THE TABLE:
Airport:
insert into airport values('&Airport_code','&Name','&City','&State');

SQL>insert into airport values('&Airport_code','&Name','&City','&State');

Ex:
Row-1: for airport table :

Enter value for airport_code: IXM


Enter value for name: Ma durai Airport

Enter value for city: Madurai

Enter value for state: Tamil Nadu


old 1: insert into airport values('&Airport_code','&Name','&City','&State')

new 1: insert into airport values('IXM','Madurai Airport','Madurai','Tamil


Nadu')

1 row created
.
Flig ht :

insert into Flight values('&Flight_number','&Airline','&Weekdays');


ex: Row-1 for leg values :

SQL>/
Enter value for flight_number: AI127

Enter value for airline: Air

India Enter value for weekdays:

Mon

old 1: insert into Flight values('&Flight_number','&Airline','&Weekdays') new 1: insert into Flight


values('AI127','Air India','Mon')

Flig ht_leg:

InsertintoFlight_Legvalues('&Flight_number','&Leg_number','&Scheduled_departure_time','&Depart
u re_airport_code','&Arrival_airport_code','&Scheduled_arrival_time');

Ex:
Enter value for flight_number: SG108

Enter value for leg_number: 1

Enter value for scheduled_departure_time: 4-may-2014,12:01:40

Enter value for departure_airport_code:HYD


Enter value for arrival_airport_code: VTZ

Enter valueforscheduled_arrival_time:5may2014,12:01:40
old1:insertintoFlight_Legvalues('&Flight_number','&Leg_

number','&Scheduled_departure_time','&Departure_airport

_code','&
Arrival_airport_code','&Scheduled_arriva l_time' ) new 1:

insert into Flight_Leg values('SG108','1','4-may-

2014,12:01:40','HYD','VTZ','5-
may2014,12:01:40')

1 row created.

Fare :

insert into Fare values('&Flight_number','&Fare_code',' &Amount','&Restrictions');

ex:

Enter value for flight_number: SG108

Enter value for fare_code: A123


Enter value for amount: 15000

Enter value for restrictions: NO ALCOHOL


old 1: insert into Fare values('&Flight_number','&Fare_code','&Amount','&Restrictions')

new 1: insert into Fare values('SG108','A123','15000','NO ALCOHOL')

1 row created.
Airplane_type :
insert into Airplane_Type values('&Airplane_type_name','&Max_seats','&Company');

Enter value for airplane_type_name: Passenger


Enter value for max_seats: 300 Enter value for company: Air India old 1: insert into

Airplane_Type values('&Airplane_type_name','&Max_seats','&Company')

new 1: insert into Airplane_Type values('Passenger','300','Air India')

1 row created.
Airplane:
insert into airplane values('&airplane_id','&total_number_of_seats','&airplane_type'

Enter value for airplane_id: SG108

Enter value for total_number_of_seats: 200 Enter value for airplane_type: Big Plane

old 1: insert into airplane

values('&airplane_id','&total_number_of_seats','&airplane_type')

new 1: insert into airplane values('SG108','200','Big Plane')

1 row created.

Leg_instance :

insertintoleg_instancevalues('&flight_number','&leg_number','&dte','&number_of_available_seats','&
airplane_id','&departure_a irport_code','&departure_time','&arrival_airport_code','&arrival_time');
Enter value for flight_number: SG108

Enter value for leg_number: 1

Enter value for dte: 04-MAY-2014

Enter value for number_of_available_seats: 200


Enter value for airplane_id: SG108

Enter value for departure_airport_code: HYD


Enter value for departure_time: 04-MAY-2014,12:01:40

Enter value for arrival_airport_code: VTZ

Enter value for arrival_time: 05-MAY-2014,12:01:40

old 1: insert into leg_instance


values('&flight_number','&leg_number','&dte','&number_of_availa ble_seats','&airplane_id','&dep
artu re_airport_code','&departure_time','&arrival_airport_code','&arrival_time')

new 1: insert into leg_instance values('SG108','1','04-MAY-2014','200','SG108','HYD',' 04-


MAY2014,12:01:40','VTZ','05-MAY-2014,12:01:40')

Seat_reservation :

insertintoseat_reservationvalues('&flight_number','&leg_number','&dte','&seat_number','&customer_
na me','&customer _phone) ;

Enter value for flight_number: SG108

Enter value for leg_number: 1


Enter value for dte: 04-MAY-

2014 Enter value for


seat_number: 1
Enter value for customer_na me:

RAMA Enter value for

customer_phone: 9003799058 old 1:


insert into seat_reservation

values('&flight_number','&leg_number','&dte','&seat_number','&customer_name','&customer_ph
one'
)

new 1: insert into seat_reservation values('SG108','1','04-MAY-2014','1','RAMA','9003799058')

1 row created.
Can_land :
insert into can_land values('&airplane_type_na me','&airport_code');

Enter value for airplane_type_name: Lowwing


Enter value for airport_code: BLR

old 1: insert into can_land

values('&airplane_type_na me','&airport_code') new 1: insert into

can_land values('Lowwing','BLR')

1 row created.
QUERY TO DATABASE:
Flight details

Id and type ofAirplane.


1.Airports that start with “K”.

1. Airports (name) in Tamilnadu

2. Seat reservation details for a given customer name and date.

3. Flight Numbers that are scheduled on Wednesday or contain INDIA in the name
3.Airplane details for which type is not known

4.Flight Leg details that has departure and arrival airport code

3.Airport details that is not in Chennai


3. Seat reservation details that are made during some particular time

4. Fare Code for amount in the r ange of 21000 to 37000

5. Airplane company name that contain exactly 2 ‘a’ in it


6. Flight leg details that has leg 5, 7

7. Maximum seats in Airplane

8. Number of Leg instances of a flight number

9. Total amount collected as fare for a given flight number

SQL PLUS FUNCTIONS:

1. Find the flight numbers booked for next day.


2. Print the company name as 'aba' translated to 'ryb'.

3. Print the months between date of reservation and todays date (only
unique dates).

4.Print the Airplane type names in Upper case


Print flight numbers with left padded stars

4. Print the first five characters of customer names.

5.Print the length of longest airport name.


6.Print System date in the format 27th Nov 2015.

7.Replace the a s present in customer names with „e .

5.Print the time in flight leg as hh-ss-mm.


5.Print the date in seat reservation in the for mat '27/11/2015'.

5. Print the arr ival time in 12hr format.

You might also like