Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

you have an e-commerce website where customers can place orders for products. You have two tables in your database: orders and inventory . The orders

you have an e-commerce website where customers can place orders for products. You have two tables in your database: orders and inventory. The orders table contains information about each customer order, such as the order number, order date, product number, quantity and total amount (we are limiting one product per order). The inventory table contains information about the products you sell, such as product name, product ID, and the number of items in stock.

You want to ensure that the inventory is updated accurately when a customer places an order, so you need to use a transaction to ensure the integrity of the data.

 

1. Should create a database with the name: ADTLab3. 

2. Should create two tables - Orders, and Inventory. Add sample data to Inventory. Submit the screenshots of successful query execution, and the screenshot of inventory table after inserting data.

-- Create a table for orders

CREATE TABLE Orders (

     order_id INT IDENTITY(1,1) PRIMARY KEY,

     order_date DATE,

     product_id INT,

     quantity INT,

     total DECIMAL(10,2)

);

 

-- Create a table for inventory

CREATE TABLE Inventory (

   Productid INT IDENTITY(1,1) PRIMARY KEY,

   product_name VARCHAR(50),

   stock_count INT,

   price DECIMAL(10, 2)

);

 

--Insert sample data into inventory table

INSERT INTO Inventory (product_name, stock_count, price) VALUES ('Shirt', 50, 19.99);

INSERT INTO Inventory (product_name, stock_count, price) VALUES ('Pants', 30, 29.99);

INSERT INTO Inventory (product_name, stock_count, price) VALUES ('Socks', 100, 4.99);

Step by Step Solution

3.44 Rating (160 Votes )

There are 3 Steps involved in it

Step: 1

1 To create a database with the name ADTLab3 we use the query create database ADTL... 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

Management Accounting Information for Decision-Making and Strategy Execution

Authors: Anthony A. Atkinson, Robert S. Kaplan, Ella Mae Matsumura, S. Mark Young

6th Edition

137024975, 978-0137024971

More Books

Students also viewed these Databases questions

Question

What does financial control mean?

Answered: 1 week ago