Database Principles Autumn 2007 High Distinction Assignment REBEL Sport Online Author: Joseph Diver
Introduction Purpose: To maintain ordering of products based on current stock levels and processing of current orders This database is also built upon the AS400 system which is required for stock levelling, delivery&installations and so on
ERD
Single-To-Many Relationship Rebel_Suppliers SupplierID CompanyName Address OfficePhoneNo FaxNo Comments Rebel_PurchaseOrders PurchaseOrderID SupplierID* DateOfCreation DueDatePurchaseOrderIDSupplierID
Many-To-Many Relationship Rebel_Orders OrderID SKU* StaffID* DelInstNo* Quantity Date_Created DueDate AusPostRef Rebel_Customers CustID FirstName LastName UnitNo StreetNo StreetName StreetType Suburb PostCode HomePhone WorkPhone MobilePhone Rebel_CustOrders CustID* OrderID*CustIDOrderID
Select Query This query selects the items which are not on order
Natural Join This query join the purchase order table with the suppliers table to find orders before 15 th of August
Cross Product This query selects the orders which have DeliveryInstallation numbers attached to them
Group By This query outputs the number of delivery or installations allocated to each supplier
Sub-Query This query selects the products with the maximum price but still have a cost under $200
Check Statement CONSTRAINT PK_StockLevel PRIMARY KEY (SKU, StoreID), CONSTRAINT FK_SKU FOREIGN KEY (SKU) REFERENCES Rebel_Items ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT FK_StoreID FOREIGN KEY (StoreID) REFERENCES Rebel_Stores ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT SKU_Length CHECK (length(SKU) = 7), CONSTRAINT StoreID_Length CHECK (length(StoreID) = 5), CONSTRAINT Level_Valid CHECK (Level >= 0), CONSTRAINT OnLayby_Valid CHECK (OnLayby >= 0), CONSTRAINT OnOrder_Valid CHECK (OnOrder >= 0), CONSTRAINT NetOnHand_Valid CHECK (NetOnHand = (OnHand - (InTransfer + OnLayby))), CONSTRAINT ValidOrdering CHECK (OnOrder <= (Level - NetOnHand))
Action Statements CONSTRAINT FK_DIStaff FOREIGN KEY (StaffID) REFERENCES Rebel_Employees ON DELETE RESTRICT -- DnI's require a staff number attached to them ON UPDATE CASCADE, CONSTRAINT FK_DISupplier FOREIGN KEY (SupplierID) REFERENCES Rebel_Suppliers ON DELETE RESTRICT -- If the Supplier disappears, the customer would be left hanging ON UPDATE CASCADE,