Docsity

Project 2 and SQL: Database Management Systems - Lecture Slides | EECS 484, Study Guides, Projects, Research of Database Management Systems (DBMS)

Partial preview of the text

Download Project 2 and SQL: Database Management Systems - Lecture Slides | EECS 484 and more Study Guides, Projects, Research Database Management Systems (DBMS) in PDF only on Docsity!

Project 2 and SQL

EECS 484

Winter '

The DUAL table

SQL> desc dual; Name Null? Type


DUMMY VARCHAR2(1)

SQL> select * from dual;

D

X

SQL> select greatest(1,3,2) from dual;

GREATEST(1,3,2)

3

SQL> select greatest(1,3,2) as max from dual;

MAX

3

Data manipulation in triggers using DUAL

SELECT .NEXTVAL INTO :NEW. FROM DUAL;

Adding a constant to tables

SQL> select * from userids;

**USERID

john jack kate ben james**

SQL> select 'lost',userid from userids;

**'LOS USERID


lost john lost jack lost kate lost ben lost james**

SQL>

Suppliers(sid, sname, address) Parts(pid, pname, color) Catalog(sid, pid, cost)

  1. Find the pnames of parts for which there is some supplier

Suppliers(sid, sname, address) Parts(pid, pname, color) Catalog(sid, pid, cost)

  1. Find the pnames of parts supplied by Acme and no one else

Suppliers(sid, sname, address) Parts(pid, pname, color) Catalog(sid, pid, cost)

  1. Find the sids of suppliers who charge more for some part than the average cost of that part (averaged over all the suppliers who supply that part)

Suppliers(sid, sname, address) Parts(pid, pname, color) Catalog(sid, pid, cost)

  1. For every supplier that only supplies green parts, print the name of the supplier and the total number of parts that he or she supplies

Schema

Flights(flno, from, to, distance, departs, arrives)

Aircraft(aid, aname, cruisingrange)

Certified(eid, aid)

Employees(eid, ename, salary)

Flights(flno, from, to, distance, departs, arrives, price) Aircraft(aid, aname, cruisingrange) Certified(eid, aid) Employees(eid, ename, salary)

  1. Find the eids of pilots certified for some Boeing aircraft.

Flights(flno, from, to, distance, departs, arrives) Aircraft(aid, aname, cruisingrange) Certified(eid, aid) Employees(eid, ename, salary)

  1. Print the names of employees who are certified only on aircrafts with cruising range longer than 1000 miles, but on at least two such aircrafts

Flights(flno, from, to, distance, departs, arrives) Aircraft(aid, aname, cruisingrange) Certified(eid, aid) Employees(eid, ename, salary)

  1. Print the names of employees who are certified only on aircrafts with cruising range longer than 1000 miles and who are certified on some Boeing aircraft