Professional Documents
Culture Documents
–MODULE-1
EXPERIMENT – 1&2&3
DATE OF ISSUE:
1. Create a table in the name of TICKET followed by last 3 digits of your roll no. having the
following attributes.
DATE OF ISSUE:
1. Create following tables followed by last 3 digits of your roll no. having the following attributes.
Client_Master: Salesman:
Client No Varchar2(6) Salesman No Varchar2(6)
Name Varchar2(25) Name Varchar2(25)
Address Varchar2(50) Address Varchar2(50)
City Varchar2(30) City Varchar2(30)
Pin Number(8) Pin Number(8)
State Varchar2(15) Salary Number(10,2)
Balance Due Number(10,2) Dept No Number(4)
Emp_Temp:
Emp No Varchar2(6)
Name Varchar2(25)
Job Varchar2(25)
Salary Number(10,2)
Dept Varchar2(20)
Dept No Number(10,2)
Product Master :
Product no Description Profit % Uom Qty on Reorder lvl Sell Cost
hand price price
P00001 1.44 Floppies 5 Piece 100 20 535 500
P03453 Monitors 6 Piece 10 3 12000 11280
P06734 Mouse 5 Piece 20 5 1050 1000
P07865 1.22 Floppies 5 Piece 100 20 525 500
P07868 Keyboards 2 Piece 10 3 3150 3050
P07885 CD Drive 2.5 Piece 10 3 5250 5100
P07965 540 HDD 4 Piece 10 3 8400 8000
P07975 1.44 Drive 5 Piece 10 3 1050 1000
P08865 1.22 Drive 5 Piece 2 3 1050 1000
Salesman_master
Salesman no Name City State Salamt Tgt_toget Ytd sales
S00001 Kiran Bombay Maharastra 3000 100 50
S00002 Manish Bombay Maharastra 3000 200 100
S00003 Ravi Bombay Maharastra 3000 200 100
S00004 Ashish Bombay Maharastra 3500 200 150
Sales_order
Orderno Odate Clientno Dely Bill yn Salesma Dely date Order stat
type n no
O19001 12-jan-05 C00001 F N S00001 20-jan-05 In Process
O19002 25-jan-05 C00002 P N S00002 27-jan-05 Cancelled
O46865 18-feb-05 C00003 F Y S00003 20-feb-05 Fulfilled
O19003 03-dec-04 C00001 F Y S00001 07-dec-04 Fulfilled
O46866 20-dec-04 C00004 P N S00002 22-dec-04 Cancelled
O19008 24-dec-05 C00005 F N S00004 26-dec-04 In Process
i. Print the description and total qty sold for each product
ii. Find the value of each product sold
iii. Calculate the average qty sold for each client that has a maximum order valu of 15000
iv. Find the sum total of all the billed orders for the month of January
Exercise on Sub-Queries :
ii. print information from client_master, product_master,sales_ordrer tables in the following format for all
the records : -
{cust_name} has placed order {order_no} on {order_Date}
RDBMS LAB. MODULE-3
EXPERIMENT – 6&7
DATE OF ISSUE:
DATE OF SUBMISSION: 2 SESSIONS
Create The Following Table , insert the given Data into the corresponding table and solve
the Queries.
TABLE Airport
airport varchar2(4) PRIMARY KEY,
aname varchar2(20),
checkin varchar2(50)
TABLE Route
routeno number(2) PRIMARY KEY ,
rdescription varchar2(40)
TABLE Fares
faretype varchar2(3) PRIMARY KEY ,
fdescription varchar2(25),
conditions varchar2(40)
TABLE Tariff
routeno number(2) not null FOREIGN KEY Route(routeno),
faretype varchar2(3) not null FOREIGN KEY Fares(faretype),
price number(10,2)
TABLE Aircraft
aircrafttype varchar2(3) PRIMARY KEY,
adescription varchar2(40),
noseats number(3)
TABLE Passenger
pid number(2) PRIMARY KEY,
Fname varchar2(20) not null,
Lname varchar2(20) not null,
address varchar2(40),
city varchar2(30),
state varchar2(2),
zipcode number(5),
telno number(10) UNIQUE,
TABLE Flight
flightno varchar2(5) PRIMARY KEY,
fromairport varchar2(4),
toairport varchar2(4),
deptime varchar2(5),
arrtime varchar2(5),
service varchar2(20),
aircrafttype varchar2(3),
routeno number(02) FOREIGN KEY Route(routeno)
TABLE Ticket
ticketno number(6) PRIMARY KEY,
ticketdate date,
pid number(2) FOREIGN KEY Passenger(pid)
TABLE Cancel
routeno number(2) not null FOREIGN KEY Route(routeno),
aircrafttype varchar2(3) not null FOREIGN KEY Aircraft(aircrafttype),
flightno varchar2(5) not null FOREIGN KEY Flight(flightno),
airport varchar2(4) not null FOREIGN KEY Airport(airport)),
fromairport varchar2(4),
toairport varchar2(4),
flightdate date,
deptime varchar2(5),
arrtime varchar2(5),
AIRP-ANAME CHECKIN
---- -------------------- --------------------------------------------
AMST-Amsterdam SHall Departures 20 mins before flight
BELF-Belfast Desks 18 and 19, 15 mins before flight
BIRM-Birmingham Check-in desks 20 mins before flight
BRUS-Brussels Sabena check-in desks 30 mins before
EMID-East Midlands Check-in 15 mins before flight
DUBL-Dublin Check-in 20 mins prior to departure
EDIN-Edinburgh Gate 1 at least 10 mins before depart
GLAS-Glasgow Desks 60-64/Gate 8 20 mins before depart
HROW-Heathrow Island A/B Terminal-1 20 mins before fl
LBDR-Leeds/Bradford Check-in 15 mins before flight for
LVPL-Liverpool 15 mins heavy baggages,10 mins hand
ROUTENO RDESCRIPTION
---------- -------------------------
3 Heathrow-Belfast
4 Heathrow-Edinburgh
6 Heathrow-Leeds/Bradford
7 Heathrow-Liverpool
8 Heathrow-Teeside
9 Birmingham-Brussels
11 East Midlands-Belfast
13 East Midlands-Paris
14 Heathrow-Birmingham
15 Heathrow-East Midlands
SQL> select * from tariff; SQL> select * from ticket;
16. Display pid, fname, lname, address, city, zipcode from passenger table
Where pid greater than equals to 25 & less than equal to 35 or lname is
like "%smith".
17. Display faretype, price, price*1.175 from tariff table where routeno
is 9 & (price*1.175) greater than 170.
18. Display faretype, price*1.175 as vatprice from tariff table Where
routeno is 9 & (price*1.175) greater than 170 order by vatprice in
descending.
19. Display noseats from aircraft & flight table where flightno is "bd80"
&aircraft's aircrafttype equals to flight's aircrafttype.
20. Display fromairport, flightno, deptime from flight table where
flightno is "bd659" & fromairport equals to fromairport & routeno
equals to routeno & deptime greater than deptime using self join.
21. Display unique flightno, fromairport, deptime, arrtime from flight
table where fromairport equals to "hrow" & toairport equals to
fromairport & toairport equals to "brus" using self join.
22. in the tariff table set the price as price + 25 where routeno=13 and
faretype=’sts’;
23. change the price in tariff as price * 1.1;
24. Delete from passenger where pid is any one of these (91, 92, 93, 94);
25. Delete from aircraft where aircrafttype is 'dc9';
26. Create or replace view brussels_link As select distinct
b.flightno,b.fromairport, B.deptime, b.arrtime From flight a, flight b
Where a.fromairport = 'hrow' And a.toairport = b.fromairport And
b.toairport = 'brus';
27. display fromairport, flightno, deptime, arrtime From brussels_link
Where deptime >= '15:00';
28. Create table ticket2 (ticketno, ticketdate, pid) by selecting rows
from ticket table.
29. Display Total no of seats from aircraft;
30. list aircrafttype From aircraft Where noseats is maximum .
31. Display unique aircrafttype records from flight table.
32. Display the passenger names in the following format where lname ends
with n;
Passenger’s name: is Anne Smithson ;
33. Delete from brussels_link;
RDBMS LAB MODULE-4 (PL/SQL 1)
EXPERIMENT-8
Duration :1 SESSION
(SUBPROGRAMS)
PROCEDURES :
FUNCTIONS :
Duration :2 SESSIONS
Q1. Create the following tables.
Table: Bank_master
Accno Number(5) primary key
Name Varchar2(15) Not Null
Open_Bal Number(5) >=500
Close_bal Number(5) >=500
Dt_opened Date default sysdate + not null
Table : Bank_Withdrawal
Accno Number(5) foreign key
With_amt number(5) not null
With_date default sysdate + not null
Table : Bank_deposit
Accno Number(5) foreign key
Depo_amt number(5) not null
Depo_date default sysdate + not null
Q2. a) Write a PL/SQL block to add an A/C holder to the Bank_master table
b) Write a PL/SQL block to accept a deposit amount from user and update the
bank_master table and the transaction should be added to the bank_deposit table.
c) Write a PL/SQL block to accept a withdraw amount from user and update the
bank_master table and the transaction should be added to the
bank_withdrawal table.
Q3 . Write PL/SQL block to accept an account number and print a ministatement of last 6
records (transactions) 3 from deposit and 3 from withdrawal table. (Use Cursors )
Q5. Create a package called Bank and incorporate all the operations as procedures/functions
in it .
Q6 . Write triggers to update the Bank_master table when ever any deposit/withdraw
transaction will held.
Q7 .Repeat Question No :4 and take care to handle all types of exceptions that can occur .
(Error Handling) .