Question: IN SQL. Part 1: Automating business procedures and automatically maintaining data integrity and consistency are critical in modern business environment. One of the most critical

IN SQL.

Part 1: Automating business procedures and automatically maintaining data integrity and consistency are critical in modern business environment. One of the most critical business procedures is proper inventory management. For example, you want to make sure that your current inventory has enough product availability that can support your product sales. Another example is to ensure that your product order is written to the supplier whenever the products inventory count drops below a certain number. Run the attached script "Products.txt" in your AdventureWorks database then create a Trigger that address the following business logic: Automatically evaluate the Products Quality On Hand value. If the value of the Products Quality On Hand is below the minimum quantity of that product, then update the Product Reorder value to 1 which means Yes to order more from the supplier.

Products.txt:

-- Create the Products table

Create table Products ( Product_Code varchar(10), Product_Desc varchar(100), Product_QOH INT, -- Product Quantity On Hand Product_MIN INT, -- Minimum Quantity of the product Product_ListPrice FLOAT, Product_MinOrder INT, -- this is the minimum quantity for restocking an order Product_ReOrder BIT -- this indicates whether the product needs to re-ordered from the vendor (1 = Yes, 0 = No)

)

-- Insert few records

INSERT INTO Products VALUES (1, 'Power Supplies', 8, 5, 35.00, 25, 0), (2, 'Hard Disks', 7, 5, 120.00, 50, 0)

-- display the Products using the SELECT statement SELECT * from Products

Submit a Word document (with screenshots) that captures the following: 1. The successful creation of the Products table 2. Data from the Products table. Hint: Run a SELECT statement 3. The successful creation and testing of the trigger

Part 2: Create an Audit log Trigger. Triggers can be used to capture and log data changes in tables. Your manager wants to be notified each time a price changes for product(s). the report/table should show the old and new price the product(s), the date of the change, and the product ID. Hint: Create a new table named it audi_log, and create a trigger to insert the required data into this table.

Submit a Word document with screen shots that captures the successful creation and testing of this trigger.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related General Management Questions!