Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

These tasks are done in court database, which you can download from Moodle. Write you SQL code right after each task. Each task gives you

These tasks are done in "court" database, which you can download from Moodle.\ Write you SQL code right after each task.\ Each task gives you 1 point, 7 points total.\ BEFORE ANSWERING THE TASKS, CREATE THESE THREE TABLES INTO COURT DATABASE\ \ -- Create the MyLogs table to store logging information\ CREATE TABLE MyLogs (\ LogID INT PRIMARY KEY,\ LogMessage VARCHAR(255),\ LogDate DATETIME\ );\ \ -- Create the Product table to store product information\ CREATE TABLE Product (\ ProductID INT PRIMARY KEY,\ ProductName VARCHAR(255),\ ProductDescription TEXT not null,\ Price DECIMAL(10, 2),\ StockQuantity INT\ );\ \ -- Create the ProductReview table to represent a 1-to-many relationship with Product\ CREATE TABLE ProductReview (\ ReviewID INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,\ ProductID INT not null,\ ReviewText TEXT not null,\ Rating INT,\ ReviewDate DATETIME,\ FOREIGN KEY (ProductID) REFERENCES Product(ProductID)\ );\ \ */\ /*\ -- Task 1 - Insert Data (Multiple Rows):\ -- Insert three new products into the Product table using a single INSERT statement. Provide the ProductName, ProductDescription, Price, and StockQuantity for each product.\ */\ \ -- Your SQL here for Task 1:\ \ /*\ -- Task 2 - Insert Data (Multiple Rows):\ -- Insert three product reviews into the ProductReview table for a specific product using a single INSERT statement. For each review, provide the ReviewText, Rating, and ReviewDate.\ */\ \ -- Your SQL here for Task 2:\ \ /*\ -- Task 3 - Update Data:\ -- Increase the price of all products in the Product table by 10%.\ */\ \ -- Your SQL here for Task 3:\ \ /*\ -- Task 4 - Delete Data:\ -- Delete all product reviews with a rating less than 3 from the ProductReview table.\ */\ \ -- Your SQL here for Task 4:\ \ /*\ -- Task 5 - Transaction:\ -- Begin a transaction. Insert three new products into the Product table. For each product, provide the ProductName, ProductDescription, Price, and StockQuantity.\ -- Insert a log message into the MyLogs table with the message "Three products added."\ -- Commit the transaction.\ */\ \ -- Your SQL here for Task 5:\ \ /*\ -- Task 6 - Subquery in Update:\ -- Begin a transaction. Update the StockQuantity of all products in the Product table to be double the average stock quantity of all products.\ */\ \ -- Your SQL here for Task 6:\ \ /*\ -- Task 7 - Transaction with Subquery:\ -- Begin a transaction. Delete all product reviews in the ProductReview table for products that have a price greater than the average price of all products.\ -- Insert a log message into the MyLogs table with the message "Deleted reviews for high-priced products."\ -- Commit the transaction.\ */\ \ -- Your SQL here for Task 7:

image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions