commit 9ce2860399d8684580da543c5dbf2aaae03e8e1f Author: noah Date: Sat Nov 26 14:14:17 2022 -0600 README diff --git a/README.md b/README.md new file mode 100644 index 0000000..69e396f --- /dev/null +++ b/README.md @@ -0,0 +1,96 @@ +# Case Study 8 + +## Instructions +- Answer questions A through G of the Morgan Importing Project found on page 450. +- Create and set up the database with the given information. +- Deliver a single sql file, along with a document that contains all the content from the sql file. +- Each query should start with a comment line that looks like: + /* *** CS8-\ *** \*/ + Example for Question A: + /* *** CS8-MI.A *** \*/ +- Do not include the result table unless specifically directed to. +- Include at least one line of white space between answers. + +## Database Information + +### Tables +EMPLOYEE (EmployeeID, LastName, FirstName, Department, Position,_Supervisor_, OfficePhone, OfficeFax, EmailAddress) + +STORE (StoreID, StoreName, City, Country, Phone, Fax, EmailAddress, Contact) + +PURCHASE_ITEM (PurchaseItemID, _StoreID_, _PurchasingAgentID_,PurchaseDate, ItemDescription, Category, PriceUSD) + +SHIPMENT (ShipmentID, _ShipperID_, _PurchasingAgentID_,ShipperInvoiceNumber, Origin, Destination, ScheduledDepartureDate,ActualDepartureDate, EstimatedArrivalDate) + +SHIPMENT_ITEM (ShipmentID, ShipmentItemID, _PurchaseItemID_,InsuredValue) + +SHIPPER (ShipperID, ShipperName, Phone, Fax, Email, Contact) + +SHIPMENT_RECEIPT (ReceiptNumber, _ShipmentID_, _PurchaseItemID_,_ReceivingAgent_, ReceiptDate, ReceiptTime, ReceiptQuantity,isReceivedUndamaged, DamageNotes) + +### Referential Integrity Constraints + +- Supervisor in EMPLOYEE must exist in EmployeeID in EMPLOYEE +- StoreID in PURCHASE_ITEM must exist in StoreID in STORE +- PurchasingAgentID in PURCHASE_ITEM must exist in EmployeeID in EMPLOYEE +- ShipperID in SHIPMENT must exist in ShipperID in SHIPPER +- PurchasingAgentID in SHIPMENT must exist in EmployeeID in EMPLOYEE +- PurchaseItemID in SHIPMENT_ITEM must exist in PurchaseItemID in PURCHASE_ITEM +- ShipmentID in SHIPMENT_RECEIPT must exist in ShipmentID in SHIPMENT +- PurchaseItemID in SHIPMENT_RECEIPT must exist in PurchaseItemID in PURCHASE_ITEM +- ReceivingAgentID in SHIPMENT_RECEIPT must exist in EmployeeID in EMPLOYEE + +### Keys and Value Restrictions + +EmployeeID of EMPLOYEE, PurchaseItemID of PURCHASE_ITEM, ShipperID of SHIPPER, ShipmentID of SHIPMENT, and ReceiptNumber of SHIPMENT_ RECEIPT are all surrogate keys with values as follows: + +| Column | Initial | Increment | +|:--------------:|:---------------:|:--------------:| +| StoreID | Start at 100 | Increment by 50 | +| EmployeeID | Start at 101 | Increment by 1 | +| PurchaseItemID | Start at 500 | Increment by 5 | +| ShipperID | Start at 1 | Increment by 1 | +| ShipmentID | Start at 100 | Increment by 1 | +| ReceiptNumber | Start at 200001 | Increment by 1 | + +Values of the Country column in the STORE table are restricted to: +- Hong Kong +- India +- Japan +- Peru +- Philippines +- Singapore +- United States + +### Motivation +James Morgan wants to modify the database design of the Morgan Importing procurement information system (MIPIS) to separate the items in PURCHASE_ITEM in a separate table named ITEM. This will allow each item to be tracked as a unique entity throughout its acquisition and sale. The schema for the ITEM table is: + +ITEM (ItemID, ItemDescription, Category) + +PURCHASE_ITEM will then be replaced by two tables named INVOICE and INVOICE_LINE_ITEM, linked in a modified sales order configuration as shown in Figure 8-7 (compare this figure to Figure 6-18(b)). + +Figure 8.7: MIPIS Modified SALES_ +ORDER Configuration +![alt text](./images/Fig_8-7.png "Figure 8-7") + +Figure 6.18b: Transformation of the Mixed Entity Pattern +![alt text](./images/Fig_6-18b.png "Figure 6-18b") + +Similarly, the shipping part of the MIPIS will be modified by changes to the SHIPMENT_ITEM tables as follows: + +SHIPMENT_LINE_ITEM (ShipmentID, ShipmentLineNumber, _ItemID_, InsuredValue) + +## Questions MI.A - MI.G +A.) Create a dependency graph that shows dependencies among the original set of tables. Explain how you need to extend this graph for views and other database constructs, such as stored procedures. + +B.) Using your dependency graph, describe the tasks necessary to create and populate the ITEM table. + +C.) Write all SQL statements to make the name change described in part B. + +D.) Using your dependency graph, describe the tasks necessary to change the name of the SHIPMENT_ITEM table to SHIPMENT_LINE_ITEM and the needed changes to column names. + +E.) Write all SQL statements to make the name change described in part D. + +F.) Using your dependency graph, describe the tasks necessary to convert the sales order component of the MIPIS to the new configuration. + +G.) Code SQL statements to implement your redesign recommendations in your answer to part F. diff --git a/images/Fig_6-18b.png b/images/Fig_6-18b.png new file mode 100644 index 0000000..4e605e9 Binary files /dev/null and b/images/Fig_6-18b.png differ diff --git a/images/Fig_8-7.png b/images/Fig_8-7.png new file mode 100644 index 0000000..96f6465 Binary files /dev/null and b/images/Fig_8-7.png differ