This project sets up a database for a construction company's e-commerce platform, allowing clients to choose finishing materials for their orders. The database schema includes tables for customers, suppliers, materials, orders, invoices, and order details. A trigger ensures data integrity by verifying that the total area specified in the orders matches the sum of areas in the order finishes.
The project helps manage a construction company's e-commerce operations by keeping track of customers, suppliers, materials, orders, invoices, and order details, while ensuring data integrity through the use of a trigger. Clients can pick their finishing materials from the website, and the system calculates the total surface area and other related metrics for the orders.
So, picture this: a client clicks through the website, selects their favorite marble slab, and voilà! Our system calculates the total surface area, crunches the numbers, and delivers a seamless order experience. It’s like magic, but with SQL.
-
Customer Table: Stores information about customers including their ID, name, surname, address, and email. The
Customer_IDis the primary key. -
Supplier Table: Stores information about suppliers including their ID, name, postal code, and email. The
Supplier_IDis the primary key. -
Material Table: Stores information about materials including their ID, name, and the supplier ID. The
Material_IDis the primary key, andSupplier_IDis a foreign key referencing theSuppliertable. -
Product Table: Stores details about products available for orders. The
Product_IDis the primary key, andMaterial_IDandSubcontractor_IDare foreign keys referencing theMaterialandSubcontractortables, respectively. -
Finish_Type Table: Stores information about different types of finishes. The
Finish_Type_IDis the primary key. -
Orders Table: Stores information about orders including order ID, customer ID, order type, product type, product location, product ID, and total area. The
Order_IDis the primary key, andCustomer_IDis a foreign key referencing theCustomertable. -
Invoice Table: Stores invoice information including invoice ID, customer ID, order ID, price, tax, dates, due date, and total. The
Invoice_IDis the primary key, andOrder_IDis a foreign key referencing theOrderstable. -
Order_Detail Table: Stores details of the orders including order detail ID, order ID, material ID, quantity, and unit price. The
Order_Detail_IDis the primary key, andOrder_IDandMaterial_IDare foreign keys referencing theOrdersandMaterialtables, respectively. -
Order_Finish Table: Stores information about the finishes applied to orders including order finish ID, order ID, finish type ID, area, and percentage. The
Order_Finish_IDis the primary key, andOrder_IDandFinish_Type_IDare foreign keys referencing theOrdersandFinish_Typetables, respectively. -
Trigger to Ensure Data Integrity: Ensures that the sum of all areas in the
Order_Finishtable for each order matches theTotal_Areain theOrderstable.
The trigger ensures that the sum of all areas in the Order_Finish table for each order matches the Total_Area in the Orders table, thereby maintaining data integrity.