Answered step by step
Verified Expert Solution
Question
1 Approved Answer
ca 4 Will use the following four tables for a product review database in the quiz. The following SQL statement tries to select number of
ca 4 Will use the following four tables for a product review database in the quiz. The following SQL statement tries to select number of reviews for all SUV (SUV is the name of a category). Please decide whether there is a bug and if so how to fix it. (30 points) select count(*) from review r, category C where c.cid = r.pid and cname = 'SUV'; --- Tables First row shows column name and type, explanation of the column, primary and foreign key (in bold) The remaining rows are some sample data Category table: stores product category. A category may have sub (parent) category. E.g., SUV and Sedan categories have the same parent category cars CID int CNAME varchar(50) Parent_CID int --- category ID, primary key --- category name --- parent category ID, foreign key references Category 2 NULL SUV 2 --- parent category is 2 (cars) Product table: stores product information PID int CID int PNAME varchar(50) --- product ID, primary key --- category ID, foreign key --- product name references category 4 Honda CR-V 4 Ford Escape Users Table: stores user information (who can write reviews) UUID int Uname varchar(50) -----User id, primary key User name Eric 2 Priya Review Table: stores review of a user for a product Rid int Pid int Uuid int Rdate date Rcomment Rating review number varchar(100) --- review ID, -- product ID date -- review comment primary key Foreign Key Foreign key rating references references users Product 2021-02-01 Most popular 1 1 3 2021-02-15 Good performance 2 3 4 2021-02-09 Improved reliability 1 4 4 For the toolbar, press ALT+F10 (PC) or ALT+FN+F10 (Mac). = = = = 3 4 1 user ID 5 4 4 for a product review database in the quiz. The following SQL statement tries to select ratings of reviews for the product named Honda CR-V. Please decide whether there are bugs in the code and if so how to fix them. (30 select rating from product p, review r where pname = Honda CR-V and pid = pid; First row shows column name and type, explanation of the column, primary and foreign key (in bold) The remaining rows are some sample data Category table: stores product category. A category may have sub (parent) category. E.g., SUV and Sedan categories have the same parent category cars CID int CNAME varchar(50) Parent_CID int --- category ID, primary key --- category name -- parent category ID, foreign key references Category 2 cars NULL 4 SUV 2 parent category is 2 (cars) Product table: stores product information PID int CID int PNAME varchar(50) - product ID, primary key --- category ID, foreign key --- product name references category 3 4 Honda CR-V 4 Ford Escape Users Table: stores user information (who can write reviews) UUID int Uname varchar(50) ---User id, primary key User name 1 Eric 2 Priya Review Table: stores review of a user for a product Rid int Pid int Uuid int Rdate date Rating Rcomment review ID, -- product ID user ID review number varchar(100) date review -- comment primary key Foreign Key Foreign key rating references references users Product 2021-02-01 5 Most popular 1 3 1 4 2021-02-15 Good performance 3 4 2 4 2021-02-09 4 4 1 Improved reliability Car the toolbar bross AT1 PC or ALTENUE10 (Mac) You will use the following four tables for a product review database in the quiz. [40 points). Please write a SQL statement to return names of users who have written at least two reviews. Tables First row shows column name and type, explanation of the column, primary and foreign key (in bold) The remaining rows are some sample data Category table: stores product category. A category may have sub (parent) category. E.g., SUV and Sedan categories have the same parent category cars CID int CNAME varchar(50) Parent_CID int --- category ID, primary key -- category name --- parent category ID, foreign key references Category 2 cars NULL 4 SUV 2 --- parent category is 2 (cars) Product table: stores product information 3 PID int CID int PNAME varchar(50) ---- product ID, primary key --- category ID, foreign key --- product name references category 4 Honda CR-V 4 4 Ford Escape Users Table: stores user information (who can write reviews) UUID int Uname varchar(50) ----------User id, primary key User name 1 Eric 2 Priya Review Table: stores review of a user for a product Rid int Pid int Uuid int Rdate date Rcomment Rating review varchar(100) -- review ID, -- product ID number review date -- comment primary key Foreign Key Foreign key rating references users references Product 1 2021-02-01 5 Most popular 3 1 4 2021-02-15 2 Good performance 3 4 2021-02-09 4 Improved reliability 4 4 1 For the toolbar, press ALT+F10 (PC) or ALT+FN+F10 (Mac). ---- user ID --- AAI
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