Question
Consider the following relational database schema Suppliers={supid,supname,address} with key {supid} Parts={partid, partname, color }with key {partid}, PartsSupplier={supid,partid,cost} with key{supid,partid} and foreign keys Query 3: List
Consider the following relational database schema Suppliers={supid,supname,address} with key {supid} Parts={partid, partname, color }with key {partid}, PartsSupplier={supid,partid,cost} with key{supid,partid} and foreign keys
Query 3: List the names of suppliers who supply every part.
Query 4: List the names of suppliers who supply every red part.
Query 5: Find pairs of supIds and partId, such that the supplier with the first supId charges more for the same part than the supplier with the second supId.
Query 6: Find the names of parts supplied by at least two different suppliers
CREATE TABLE suppliers ( supId NUMBER(7) NOT NULL, supName VARCHAR2(25) NOT NULL, address VARCHAR2(50), CONSTRAINT pk_suppliers PRIMARY KEY ( supId ) );
CREATE TABLE parts( partId NUMBER(7) NOT NULL, partName VARCHAR2(15) NOT NULL, color VARCHAR2(10), CONSTRAINT pk_parts PRIMARY KEY ( partId ) );
CREATE TABLE partsSuppliers ( supId NUMBER(7) NOT NULL, partId NUMBER(7) NOT NULL, partCost NUMBER(7, 2) NOT NULL, CONSTRAINT pk_partsSuppliers PRIMARY KEY ( partId, supId ), CONSTRAINT fk_partsSuppliersParts FOREIGN KEY ( partId ) REFERENCES parts(partId), CONSTRAINT fk_partsSuppliersSuppliers FOREIGN KEY ( supId ) REFERENCES suppliers(supId) );
INSERT INTO suppliers (supId, supName, address) WITH newSuppliers AS ( SELECT 1, 'Supplier 1', 'Vancouver, BC' FROM dual UNION ALL SELECT 2, 'Supplier 2', 'Abbotsford, BC' FROM dual UNION ALL SELECT 3, 'Supplier 3', 'Toronto, ON' FROM dual UNION ALL SELECT 4, 'Supplier 4', 'Chilliwack, BC' FROM dual ) SELECT * FROM newSuppliers; INSERT INTO parts (partId, partName, color) WITH newParts AS ( SELECT 1, 'Part 1', 'RED' FROM dual UNION ALL SELECT 2, 'Part 2', 'RED' FROM dual UNION ALL SELECT 3, 'Part 3', 'GREEN' FROM dual UNION ALL SELECT 4, 'Part 4', 'BLUE' FROM dual ) SELECT * FROM newParts;
INSERT INTO partsSuppliers (partId, supId, partCost) WITH newPartsSuppliers AS ( SELECT 2, 1, 25.0 FROM dual UNION ALL SELECT 1, 1, 12.5 FROM dual UNION ALL SELECT 3, 1, 30 FROM dual UNION ALL SELECT 4, 1, 44.5 FROM dual UNION ALL SELECT 1, 2, 25.5 FROM dual UNION ALL SELECT 2, 2, 44.0 FROM dual UNION ALL SELECT 3, 3, 33.5 FROM dual UNION ALL SELECT 4, 3, 22.50 FROM dual UNION ALL SELECT 1, 4, 14.5 FROM dual UNION ALL SELECT 2, 4, 24.0 FROM dual UNION ALL SELECT 3, 4, 34.5 FROM dual UNION ALL SELECT 4, 4, 44.0 FROM dual ) SELECT * FROM newPartsSuppliers;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started