You are on page 1of 46

CYCLE SHEET 1

DATABASE MANAGEMENT SYSTEMS (SWE1004)

NAME: P. MAHITHA
REG NO.: 17MIS0458
SLOT: L1+L2
FACULTY: PROF. JAYARAM REDDY
TABLE CREATIONS

create table AIRPORT

(Airport_code varchar2(30),
Name varchar2(30) not null,
City varchar2(15) not null,
State varchar2(15) not null,
PRIMARY KEY(Airport_code));

create table FLIGHT


(Flight_numbervarchar2(10) ,
Airline varchar2(25) not null,
Weekdays varchar2(30) ,
PRIMARY KEY(Flight_number));

create table FLIGHT_LEG


(Flight_number varchar2(30),
Leg_numbernumber(30),
Scheduled_departure_time timestamp not null,
Departure_airport_code varchar2(30) not null,
Arrival_airport_code varchar2(30) not null,
Scheduled_arrival_time timestamp not null,
CONSTRAINT pk_fl PRIMARY
KEY(Flight_number,Leg_number));
create table LEG_INSTANCE
(Flight_number varchar2(10),
Leg_numbernumber(5),
Date1 date,
Number_of_available_seatsnumber(4) not null,
Airplane_id varchar2(10) not null,
Departure_airport_code varchar2(10) not null,
Departure_time timestamp not null,
Arrival_airport_code varchar2(10) not null,
Arrival_time timestamp not null,
CONSTRAINT pk_li PRIMARY
KEY(Flight_number,Leg_number,Date1));

create table FARE


(Flight_number varchar2(10),
Fare_code varchar2(10),
amount number(5) not null,
Restriction varchar2(30) not null,
CONSTRAINT pk_f PRIMARY KEY(Flight_number,Fare_code));

create table AIRPLANE_TYPE


(Airplane_type_name varchar2(15),
Max_seatsnumber(3) not null,
Company varchar2(25) not null,
CONSTRAINT pk_at PRIMARY KEY(Airplane_type_name));
create table CAN_LAND
(Airplane_type_name varchar2(15),
Airport_code varchar2(10),
CONSTRAINT pk_cl PRIMARY
KEY(Airplane_type_name,Airport_code));

create table AIRPLANE


(Airplane_id varchar2(10),
Total_number_of_seatsnumber(3) not null,
Airplane_type varchar2(15) not null,
PRIMARY KEY(Airplane_id))
create table SEAT_RESERVATION
(Flight_number number(10),
Leg_numbernumber(5),
Date2 date,
Seat_numbernumber(3),
Customer_name varchar2(15) not null,
Customer_phonenumber(10) not null,
CONSTRAINT pk_sr PRIMARY
KEY(Flight_number,Leg_number,Date2,Seat_reservation);
INSERTING VALUES INTO TABLES:

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


 insert into Flight
values('&Flight_number','&Airline','&Weekdays');
 insert into
Flight_Legvalues('&Flight_number','&Leg_number','&Scheduled
_departure_time','&Departu
re_airport_code','&Arrival_airport_code','&Scheduled_arrival_ti
me');
 insert into Fare
values('&Flight_number','&Fare_code','&Amount','&Restrictions')
;
 insert into Airplane_Type
values('&Airplane_type_name','&Max_seats','&Company');
 insert into can_land
values('&airplane_type_name','&airport_code');
 insert into airplane
values('&airplane_id','&total_number_of_seats','&airplane_type');
 insert into leg_instance
values('&flight_number','&leg_number','&dte','&number_of_ava
ilable_seats','&airplane_id','
&departure_airport_code','&departure_time','&arrival_airport_co
de','&arrival_time');
 insert into seat_reservation
values('&flight_number','&leg_number','&dte','&seat_number','&
customer_name','&customer _phone)
TABLES:
Query the Db to display:

1. The flight details:


2. Id and type of Airplane:

3. Airports that start with “K”:


4. Airports (name) in Tamilnadu:

5. Seat reservation details for a given customer name and date:

6. Flight numbers that are scheduled on Wednesday or contain India in


the name:

7. Airplane details for which type is not known:


8. Flight leg details that has a departure and arrival airport code:
9. Airport details that is not in 'Chennai':
10) Seat reservations that are made during last month:

11)Fare code for amount in range 21000 to 37000:

12)Airplane company names that contains exactly 3 'S' in it:

As there are no company with 3’s in my database it is displaying as no


rows selected.
13)Flight leg details that has leg #s 1, 3, and 4:
14. Maximum seats in airplane:

15. Number of leg instances of a flight number:

16. Total amount collected as fare for a given flight number:

B. Alter the tables to

1)Add required foreign keys:


. 2)Make name of airport as Unique and weekdays as not null:
3)Make weekdays as multivalued attribute:
4)Increase the size of flight airline:
5)Convert fare amount to decimal type:

6) Decrease the size of fare restriction:

Table altered;

7)Delete the column added in Q.9:

8)Add a column seat reservation address in table:


UPDATING THE TABLE SEAT RESERVATION:
After updation:
9)Add column country in airport table:
10)UPDATING THE TABLE AIRPORT:

AFTER UPDATION THE TABLE IS:


C. Create the ASSERTIONS:

1. Flight number should be in the range 1000 to 2000:


2. Country in airport must be India, USA, UAE, Malaysia, South
Africa:
3)No of weekdays of flight is not more than 3:
Sunday is the output.
D. Queries on SQL * PLUS functions:

2)Find the flight numbers booked for tomorrow:

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:

5)Print flight numbers with left padded stars:


6)Print the first five characters of customer names:

7)Print the length of longest airport name:


8)Print System date in the format 27th Nov 2015:

9)Replace the “a‟s present in customer names with “e”:

10)Print the time in flight leg as hh-ss-mm:


11)Print the date in seat reservation in the format '27/11/2015':

12)Print the arrival time in 12hr format:

You might also like