Question: Assignment: Customer Orders Management System Objective: Build a simple database management system for a fictional company that tracks customer orders and inventory levels. Use stored
Assignment: Customer Orders Management System
Objective:
Build a simple database management system for a fictional company that tracks customer
orders and inventory levels. Use stored procedures to handle data manipulations and
triggers to maintain data integrity and perform logging actions.
Part : Database Setup
Create Tables:
Students will create the following tables:
Customers: Contains customer details.
Fields: CustomerID primary key CustomerName, ContactName,
Country
Products: Contains product details.
Fields: ProductID primary key ProductName, Price, QuantityAvailable
Orders: Records orders placed by customers.
Fields: OrderID primary key CustomerID foreign key OrderDate,
TotalAmount
OrderDetails: Records details about each product ordered.
Fields: OrderDetailID primary key OrderID foreign key ProductID
foreign key Quantity, Price
Populate Tables:
Provide a set of sample data to populate these tables or instruct students to create
their own realistic data.
Part : Stored Procedures
Create a Stored Procedure AddNewOrder:
This procedure should accept details for a new order, including customer ID an
array of product IDs, and their quantities. The procedure should:
Insert a new order into the Orders table.
Update the OrderDetails table for each product ordered.
Calculate the total amount for the order and update the Orders table.
Ensure the product quantity is available before confirming the order.
Create a Stored Procedure UpdateOrder:
This procedure should allow updating the quantity of products in an existing order. It
should check for product availability before making changes.
Part : Triggers
Inventory Management Trigger:
Create an AFTER INSERT and AFTER UPDATE trigger on the OrderDetails table to
automatically update the QuantityAvailable in the Products table whenever an
order is placed or updated.
Logging Trigger:
Create an AFTER INSERT trigger on the Orders table that logs each new order into
an OrderLog table. The OrderLog table should have fields for LogID, OrderID,
LoggedTime, and Action eg 'New Order Placed'
Part : Testing and Validation
Students must write SQL queries to demonstrate the functionality of their stored
procedures and triggers.
They should include test cases where orders exceed the available product quantity
and show how the system handles these situations.
Deliverables:
SQL script for creating tables and inserting sample data.
SQL script for stored procedures and triggers.
A report documenting the functionality of each component, including test cases
and their outcomes.
Evaluation Criteria:
Correctness of SQL syntax and logic.
Effective use of stored procedures for encapsulating business logic.
Correct implementation of triggers to ensure data integrity and perform auxiliary
actions.
Quality and clarity of the documentation and test cases.
Grading Rubric for Customer Orders Management System Assignment
Correctness of SQL Scripts points
Tables Creation points: Properly defined tables with all required fields and
constraints.
Correct data types and field sizes points
Appropriate use of primary and foreign keys points
Stored Procedures points: Correctly implemented stored procedures that
perform the expected operations without errors.
Logical implementation of AddNewOrder procedure points
Logical implementation of UpdateOrder procedure points
Triggers points: Triggers should accurately perform the tasks as specified,
updating and logging data correctly.
Inventory management trigger functions correctly after insertsupdates
points
Order logging trigger captures new orders accurately points
Execution and Testing points
Functional Testing points: Demonstrates that all database operations perform
as intended through provided test cases.
Test cases cover all functionalities points
Test cases validate boundary conditions and error handling points
Result Validation points: Clear evidence is provided that the system behaves
as expected, with sample outputs and explanations.
Correctness of outputs for given inputs points
Detailed explanation correlating outputs with expected outcomes points
Documentation and Presentation points
Code Documentation points: SQL scripts are welldocumented with
comments explaining the purpose of functions, procedures, and trigger logic.
Comments on major sections of the code points
Inline comments for complex logic points
Report Quality points: Submission includes a clear, coherent report that
explains the design, functionality, and testing process.
Clarity and structure of the report points
Depth of discussion on testing and outcomes points
Bonus Points up to extra points: Exceptional work, such as
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
