Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using the schema (Data tables) below in the petstore_schema.sql, write queries s

ID: 3915464 • Letter: U

Question

Using the schema (Data tables) below in the petstore_schema.sql, write queries shown below.

petstore_schema.sql UNREGISTERED 16 CREATE TABLE Pets 17 18 19 20 21 ID TEXT PRIMARY KEY Name TEXT, Species TEXT, Color TEXT, Age INT, Price DECIMAL); 23 24 CREATE TABLE Supplies( 25 26 27 28 29 CREATE TABLE Customers ( 30 31 32 UPC INT PRIMARY KEY Name TEXT, Price DECIMAL); ID INT PRIMARY KEY AUTOINCREMENT, Name TEXT, Phone TEXT, Address TEXT) 34 35 36 37 38 39 40 41 42 43 CREATE TABLE Transactions( ID INT PRIMARY KEY AUTOINCREMENT, date' DATE, cashin DECIMAL); CREATE TABLE PetSales ( Foreign keys that reference other tables, 3 FK TransactionID INT, PetID TEXT, CustomerID INT PRIMARY KEY (TransactionID, PetID), FOREIGN KEY (PetID) REFERENCES Pets (ID), FOREIGN KEY (CustomerID) REFERENCES Customers (ID), FOREIGN KEY (TransactionID) REFERENCES Transactions (ID)); 45 46 47

Explanation / Answer

1. SELECT Name FROM Pets WHERE Species = 'dog';

2. SELECT c.Name FROM Customers c, Pets p, PetSales ps WHERE c.ID = ps.CustomerID AND ps.PetID = p.ID AND p.Species = 'dog';

3. SELECT Name FROM Customer WHERE ID = (SELECT CustomerID FROM SupplySales WHERE quantity = (SELECT max(quantity) FROM SupplySales));

4. SELECT c.Name FROM Customers c, Pets p, PetSales ps WHERE c.ID = ps.CustomerID AND ps.PetID = p.ID AND p.Name = 'Kiki';

NOTE: As per Chegg policy, I can answer only 4 questions in a single post. Please post the rest questions separately and I will try to answer them.