I have three tables:
product(pid,name,category,maker-cid)
purchase(buyer-ssn,seller-ssn,quantity,pid)
person(ssn,name,phone number,city)
How can I create a view to expose only the Buyer name, Seller name and product name from all transactions?
I have three tables:
product(pid,name,category,maker-cid)
purchase(buyer-ssn,seller-ssn,quantity,pid)
person(ssn,name,phone number,city)
How can I create a view to expose only the Buyer name, Seller name and product name from all transactions?
You just need to join the tables, projecting out the columns you need and wrap that in a view. For example:
CREATE VIEW "view name"
AS
SELECT
B.Name "Buyer Name",
S.Name "Seller Name",
PRD.Name "Product Name"
FROM Purchase PUR
JOIN Person B
ON B.ssn = PUR."buyer-ssn"
JOIN Person S
ON S.ssn = PUR."seller-ssn"
JOIN Product PRD
ON PRD.pid = PUR.pid;