Consider a database consisting of the following relations, where the primary key
ID: 3909356 • Letter: C
Question
Consider a database consisting of the following relations, where the primary key of each relation is underlined. Product (pid, name, price, category, maker-cid) Purchase (buyer-sin, seller-sin, store, pid) Company (cid, name, stock price, country) Person (sin, name, phone number, city) Express the below queries in RA and Datalog 1. [4 Marks] Find the name of all products 2. [4 Marks] Find all purchases with the same buyer and seller. 3. [4 Marks] Find all products over $99.99 4. [4 Marks] Find SINs of people who bought products in the "computers" category 5. [6 Marks] Find pairs of products (pid's) of the same category but with different makers. Avoid duplicate pairs, e.g., (p1, p2) and (p2, p1) shouldn't both appear in the answer 6. [6 Marks) Find the sin and name of persons who bought every product in the category 7. [6 Marks] Find the pid of the product under category laptop that had the highest price "electronics" within its category.Explanation / Answer
1. SELECT DISTINCE name FROM Product;
2. SELECT * FROM Purchase where buyer-sin = seller-sin;
3. SELECT * FROM Product WHERE price > 99.99;
4. SELECT sin FROM Person WHERE sin in (SELECT pu.buyer-sin FROM Purchase pu JOIN Product p ON pu.pid = p.pid WHERE p.category = 'computers');
NOTE: Due to Chegg policy, I can answer only four questions. Hence, I request you to post the remaining questions separately and I will try to answer it. Sorry for the incovenience.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.