0% found this document useful (0 votes)
73 views

SQL6

The document describes an airline database with tables for flights, aircrafts, employees, and employee certifications. It provides sample data and queries on the tables including finding aircraft certified employees with high salaries, aircraft and salaries for experienced pilots, pilots cheaper than a flight, aircraft and average salaries, and aircraft for a given route.

Uploaded by

Nageen Chand
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views

SQL6

The document describes an airline database with tables for flights, aircrafts, employees, and employee certifications. It provides sample data and queries on the tables including finding aircraft certified employees with high salaries, aircraft and salaries for experienced pilots, pilots cheaper than a flight, aircraft and average salaries, and aircraft for a given route.

Uploaded by

Nageen Chand
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

AIRLINE DATABASE

6. Consider the following database for AIRLINE FLIGHT


INFORMATION.
FLIGHT(flno: int, fromplace: string, toplace: string, distance: int, departs:
string, arrives: string, price: real)
AIRCRAFT( aid: int, aname : string, crange: int)
EMPLOYEES( eid: int, ename: string, salary: int)
CERTIFIED(eid: int, aid: int)
a. Create the above tables by properly specifying the primary keys and
foreign keys.
b. Enter at least 5 tuples for each relation.
c. Find the names of aircraft such that all certified to operate them have a
salaries more than Rs.80,000.
d. For each pilot who certified for more than three aircraft , find the three
aircrafts, find the eid and the maximum crusingrange of the aircraft for
which he or she certified.
e. Find the names of the pilots whose salary is less than the price of the
cheapest route from Bangalore to FrankFrut.
f. For all aircraft with crusingrange over 1000kms . Find the name of the
aircraft and the average salary of all pilots certified for this aircraft.
g. Find the names of the pilots certified for some being aircraft.
h. Find the aids of all aircrafts that can be used on routes from Bangalore to
New Delhi.
TABLE CREATION:

SQL> Create table flight(flno number(5)primary key,fromplace varchar2(15),toplace


varchar2(15),distance number(5),departs varchar2(8),arrives varchar2(8),price number(6));

SQL> Create table aircraft(aid number(5)primary key,aname varchar2(10),crange


number(5));

SQL> Create table employees(eid number(5)primary key,ename varchar2(10),salary


number(7));

SQL> Create table certified(eid number(9)references employees(eid),aid


number(9)references aircraft(aid));

INSERTING VALUES TO TABLES

SQL> insert into flight


values('&flno','&fromplace','&toplace','&distance','&departs','&arrives','&price');
Enter value for flno: 100
Enter value for fromplace: losangels
Enter value for toplace: honlulu
Enter value for distance: 1000
Enter value for departs: 1:44:44
Enter value for arrives: 10:00:00
Enter value for price: 50000

SQL> /
Enter value for flno: 200
Enter value for fromplace: losangels
Enter value for toplace: chicago
Enter value for distance: 1200
Enter value for departs: 19:44:44
Enter value for arrives: 23:00:00
Enter value for price: 20000

SQL> /
Enter value for flno: 300
Enter value for fromplace: india
Enter value for toplace: chicago
Enter value for distance: 9000
Enter value for departs: 12:44:44
Enter value for arrives: 16:00:00
Enter value for price: 10000

SQL> /
Enter value for flno: 400
Enter value for fromplace: bangalore
Enter value for toplace: delhi
Enter value for distance: 900
Enter value for departs: 10:44:49
Enter value for arrives: 11:40:00
Enter value for price: 10000

SQL> /
Enter value for flno: 500
Enter value for fromplace: bangalore
Enter value for toplace: frankfurt
Enter value for distance: 700
Enter value for departs: 1:55:55
Enter value for arrives: 06:05:45
Enter value for price: 5000

SQL> /
Enter value for flno: 600
Enter value for fromplace: madilon
Enter value for toplace: newyork
Enter value for distance: 800
Enter value for departs: 2:05:15
Enter value for arrives: 06:00:00
Enter value for price: 7000

SQL> /
Enter value for flno: 700
Enter value for fromplace: madilon
Enter value for toplace: newyork
Enter value for distance: 600
Enter value for departs: 4:00:00
Enter value for arrives: 7:00:00
Enter value for price: 10000
.
SQL> insert into aircraft values('&aid','&aname','&crange');
Enter value for aid: 1
Enter value for aname: airindia
Enter value for crange: 1000

SQL> /
Enter value for aid: 2
Enter value for aname: boeing
Enter value for crange: 5000

SQL> /
Enter value for aid: 3
Enter value for aname: kingfisher
Enter value for crange: 9500

SQL> /
Enter value for aid: 4
Enter value for aname: sahara
Enter value for crange: 8500

SQL> /
Enter value for aid: 5
Enter value for aname: airgo
Enter value for crange: 3500

SQL> insert into employees values('&eid','&ename','&salary');


Enter value for eid: 10
Enter value for ename: kumar
Enter value for salary: 2000

SQL> /
Enter value for eid: 11
Enter value for ename: pratap
Enter value for salary: 8000

SQL> /
Enter value for eid: 12
Enter value for ename: chaitali
Enter value for salary: 130000

SQL> /
Enter value for eid: 13
Enter value for ename: vinod
Enter value for salary: 20000

SQL> /
Enter value for eid: 14
Enter value for ename: darshan
Enter value for salary: 150000

SQL> /
Enter value for eid: 15
Enter value for ename: manish
Enter value for salary: 4000

SQL> /
Enter value for eid: 16
Enter value for ename: ankith
Enter value for salary: 40000

SQL> insert into certified values('&eid','&aid');


Enter value for eid: 10
Enter value for aid: 3

SQL> /
Enter value for eid: 11
Enter value for aid: 1

SQL> /
Enter value for eid: 12
Enter value for aid: 1

SQL> /
Enter value for eid: 12
Enter value for aid: 2

SQL> /
Enter value for eid: 12
Enter value for aid: 4

SQL> /
Enter value for eid: 13
Enter value for aid: 5

SQL> /
Enter value for eid: 14
Enter value for aid: 1
QUERY-1

SQL> select distinct aname from aircraft a,certified c,employees e where a.aid=c.aid and
c.eid=e.eid and e.salary>80000;

ANAME
----------
boeing
airindia
sahara

QUERY-2

SQL> select eid,max(crange)from aircraft a,certified c where a.aid=c.aid group by c.eid


having count(c.aid)>2;

EID MAX(CRANGE)
---------- -----------
12 8500

QUERY-3

SQL> select ename from employees where salary<(select min(price) from flight where
fromplace='bangalore' and toplace='frankfurt');

ENAME
----------
kumar
manish

QUERY-4

SQL> select aname,avg(salary)from aircraft a,employees e,certified c where a.aid=c.aid and


c.eid=e.eid and a.crange>1000 group by aname;

ANAME AVG(SALARY)
---------- -----------
boeing 130000
airgo 20000
kingfisher 2000
sahara 130000

QUERY-5

SQL> select ename from aircraft a,certified c,employees e where a.aid=c.aid and c.eid=e.eid
and aname='boeing';

ENAME
----------
Chaitali
QUERY-6

SQL> select aid from aircraft where crange>(select min(distance) from flight where
fromplace='bangalore' and toplace='delhi');

AID
----------
1
2
3
4
5

You might also like