Question

In: Other

Consider the following schema: Suppliers (sid, sname, address) Parts (pid, pname, colour) Catalog(sid, pid, cost) The key for Suppliers is sid, for Parts is pid, and for Catalog is sid and pid The Ca...

Consider the following schema: 

Suppliers (sid, sname, address) 

Parts (pid, pname, colour) 

Catalog(sid, pid, cost) 


The key for Suppliers is sid, for Parts is pid, and for Catalog is sid and pid The Catalog relation associates prices charged for parts by suppliers. 


Write the following queries using relational algebra. For items (a) through (e), use the "sequences of assignments" form. For items (f) and (g), use the "expression tree" form. List all assumptions. (Some marks will be given for the quality of your answers.) 

(a) Find the names of suppliers who supply some blue part. 

(b) Find the ids of suppliers who supply some blue or magenta part.

 (c) Find the ids of suppliers who supply every magenta part. 

(d) Find the ids of suppliers who supply every part. 

(e) Find the ids of parts supplied by at least two different suppliers 

(f) Find the ids of the most expensive parts supplied by company name named "Screw-2-You Limited". 

(g) Find the ids of parts supplied by every supplier at less than or equal to $50. (If any supplier either does not supply the part or charges more than $50 for it, then that part should not be in the final relation.)


Solutions

Expert Solution

-- 1 supplier supplies only blue part

πsname(πsid((πpidσcolor=_’blue’_Parts) Catalog) Suppliers)

--2 supplier supplies either of colour

πsid(πpid(σcolor=’blue’∨ color=’magenta’ Parts) catalog)

--3 supplier supplies every magenta part

(πsid,pid Catalog)/(πpid σcolor=’magenta’ Parts)

--4 Below query to get supplier supplies every part

(πsid,pid Catalog)/(πpid Parts)

As per HOMEWORKLIB RULES we csn only solve 1st 4 sub questions.


Related Solutions

INRO TO DATABASES Consider the following Schema: Suppliers(sid: integer, sname: string, address: string) Parts(pid: integer, pname:...
INRO TO DATABASES Consider the following Schema: Suppliers(sid: integer, sname: string, address: string) Parts(pid: integer, pname: string, color: string) Catalog(sid: integer, pid: integer, cost: real) The Catalog relation lists the prices charged for parts by Suppliers. Write the following queries in SQL using join, nested queries and set operators. 1. Find names of suppliers who supply every red or green part. 2. Find the sids of suppliers who supply every red part or supply every green part. 3. Find sids...
Consider the University Database with the following relations: Professors (pid, pname, dept, ext) Students (sid, sname,...
Consider the University Database with the following relations: Professors (pid, pname, dept, ext) Students (sid, sname, major-dept, year) Courses (cid, cname, dept, credithours) Enrollment (sem-year, sid, cid, grade) Teaches (pid, cid, sem-year, class-size) where, Professors: All professors have professor id (pid), name (pname), department that they work (dept), and a phone number extension for their office (ext). Students: All students have id (sid), name (sname), department for their major (major-dept), and a year (year i.e, freshman, sophomore, junior, etc). Courses:...
Consider the University Database with the following relations: Professors (pid, pname, dept, ext) Students (sid, sname,...
Consider the University Database with the following relations: Professors (pid, pname, dept, ext) Students (sid, sname, major-dept, year) Courses (cid, cname, dept, credithours)Enrollment (sem-year, sid, cid, grade) Teaches (pid, cid, sem-year, class-size), Professors: All professors have professor id (pid), name (pname), department that they work (dept), and a phone number extension for their office (ext). Students: All students have id (sid), name (sname), department for their major (major-dept), and a year (yeari.e, freshman, sophomore, junior, etc). Courses: All courses have...
Consider the following schema and functional dependencies: SHIPPING (ShipName, ShipType, VoyageID, Cargo, Port, ArrivalDate) Key: ShipName,...
Consider the following schema and functional dependencies: SHIPPING (ShipName, ShipType, VoyageID, Cargo, Port, ArrivalDate) Key: ShipName, ArrivalDate FD1: ShipName > ShipType FD2: VoyageID > ShipName, Cargo FD3: ShipName, ArrivalDate > VoyageId, Port 1.Please list the final set of 3NF schema including all its keys. 2.Do any of the finalized 3NF schema have determinates that are not candidate keys? If yes, explain - which schema(s)? Why?  
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT