Docsity

SQL NESTED QUERIES CODE PRACTICE, Lab Reports of Database Management Systems (DBMS)

Toggle sidebar
bg1
NUST
Military College of Signals,
Rawalpindi.
DATABASE SYSTEM
LAB # 7
BATCH-26C
Submitted By:
AYMEN FATIMA
CMS ID:
345556
Submitted To:
Sir Kabeer Ahmed
DEPARTMENT OF COMPUTER SOFTWARE ENGINEERING.
MILITARY COLLEGE OF SIGNALS.
pf3
pf4
pf5

Partial preview of the text

Download SQL NESTED QUERIES CODE PRACTICE and more Lab Reports Database Management Systems (DBMS) in PDF only on Docsity!

NUST

Military College of Signals,

Rawalpindi.

DATABASE SYSTEM

LAB # 7

BATCH-26C

Submitted By:

AYMEN FATIMA

CMS ID:

Submitted To:

Sir Kabeer Ahmed

DEPARTMENT OF COMPUTER SOFTWARE ENGINEERING.

MILITARY COLLEGE OF SIGNALS.

EXPERIMENT 7 – Nested Queries

Lab# 5 EXCERCISE (15 marks)

Problem 7.1 :

Display all eventno, datereq and estcost, whose estcost is lesser than maximum estcost of

current requested events.

Select EventNo, Datereq, Estcost from EventRequest where estcost< (Select Max(Estcost) from EventRequest)

Problem 7.2 :

Write a query to find all the customers who’s city is same as ‘Babar Nawaz’.

Select * from Customer where city=(Select city from Customer where custname='Babar Nawaz')

Problem 7.3 :

Write a query to display information of Eventrequest which has estcost more than any

Approved event.

Select * from EventRequest where estcost > (Select MAX(estcost) from EventRequest where status='Approved')

Problem 7.4 :

Write a query to list all the eventrequest, which has estcost < then average estcost of events.

Select * from EventRequest where estcost < (Select AVG(estcost) from EventRequest )

Problem 7.5:

a. List all event planed, which are in operation or setup using IN operator.

Select * from EventPlan where activity In('setup','operation')

b. List all event requested, which has estimated cost is greater than all pending events

using ALL operator.

ResourceTbl

EventRequest EventPlanLine EventPlan

 - R100 attendant $10. resno resname rate - R101 police $15. - R102 usher $10. - R103 nurse $20. - R104 janitor $15. - R105 food service $10. 
  • E100 25-Oct-2018 06-Jun-2018 F100 C100 08-Jun-2018 Approved $5,000.00 80000 B eventno dateheld datereq facno custno dateauth status estcost estaudience budno
  • E101 26-Oct-2018 28-Jul-2018 F100 C100 Pending $5,000.00 80000 B
  • E102 14-Sep-2018 28-Jul-2018 F100 C100 31-Jul-2018 Approved $5,000.00 80000 B
  • E103 21-Sep-2018 28-Jul-2018 F100 C100 01-Aug-2018 Approved $5,000.00 80000 B
  • E104 03-Dec-2018 28-Jul-2018 F101 C101 31-Jul-2018 Approved $2,000.00 12000 B
  • E105 05-Dec-2018 28-Jul-2018 F101 C101 01-Aug-2018 Approved $2,000.00 10000 B
  • E106 12-Dec-2018 28-Jul-2018 F101 C101 31-Jul-2018 Approved $2,000.00 10000 B
  • E107 23-Nov-2018 28-Jul-2018 F100 C105 31-Jul-2018 Denied $10,000.00 - P100 1 8:00 17:00 2 L100 R PlanNo LineNo TimeStart TimeEnd NumberFld LocNo ResNo - P100 2 12:00 17:00 2 L101 R - P100 3 7:00 16:30 1 L102 R - P100 4 18:00 22:00 2 L100 R - P101 1 18:00 20:00 2 L103 R - P101 2 18:30 19:00 4 L105 R - P101 3 19:00 20:00 2 L103 R - P102 1 18:00 19:00 2 L103 R - P102 2 18:00 21:00 4 L105 R - P102 3 19:00 22:00 2 L103 R - P103 1 18:00 21:00 2 L103 R - P103 2 18:00 21:00 4 L105 R - P103 3 19:00 22:00 2 L103 R - P104 1 18:00 22:00 4 L101 R - P104 2 18:00 22:00 4 L100 R - P105 1 18:00 22:00 4 L101 R - P105 2 18:00 22:00 4 L100 R - P199 1 8:00 12:00 1 L100 R - P349 1 12:00 15:30 1 L103 R - P85 1 9:00 17:00 5 L100 R - P85 2 8:00 17:00 2 L102 R - P85 3 10:00 15:00 3 L104 R - P95 1 8:00 17:00 4 L100 R - P95 2 9:00 17:00 4 L102 R - P95 3 10:00 15:00 4 L106 R - P95 4 13:00 17:00 2 L100 R - P95 5 13:00 17:00 2 L101 R
    • P100 E100 25-Oct-2018 Standard operation Operation E planno eventno workdate notes activity empno
    • P101 E104 03-Dec-2018 Watch for gate crashers Operation E
    • P102 E105 05-Dec-2018 Standard operation Operation E
    • P104 E101 26-Oct-2018 Standard cleanup Cleanup E P103 E106 12-Dec-2018 Watch for seat switching Operation
    • P105 E100 25-Oct-2018 Light cleanup Cleanup E
    • P199 E102 10-Dec-2018 Standard operation Operation E
    • P299 E101 26-Oct-2018 Operation E

P349 E106 12-Dec-2018 Cleanup E P85 E100 25-Oct-2018 Standard operation Setup E P95 E101 26-Oct-2018 Extra security Setup E

Primary and Foreign Keys

The primary and foreign keys are depicted in Figure 1. An event request is related to many (one or

more) event plans but only one customer. An event plan contains many event plan lines but only

one supervising employee. An event plan line references a resource and location. A facility has

many locations, but a location is specific to a facility.

Figure 1: Oracle Relational Database Diagram for the Intercollegiate Athletic Database