|
Fall Semester 2002 |
Key Terms
Chapter Outline
I. Introduction II. User Views III. Information-Level Design Methodology IV. Represent a User View as a Collection of Tables V. Normalize the Tables VI. Represent All Keys A. Database Design Language (DBDL) B. Entity-Relationship Diagrams VII. Merge the Result into the Design VIII. Database Design Examples IX. Physical-Level Design X. Entity-Relationship Diagram Alternatives XI. Top-Down Versus Bottom-up XII. Survey Form XIII. Obtaining Information from Existing Documents XIV. One-to-One Relationship Considerations XV. Many-to-Many Relationship Considerations XVI. Nulls and Entity Subtypes XVII. Avoiding Problems with Third Normal Form When Merging Tables XVIII. Summary XIX. Key Terms XX. Review Questions XXI. Premiere Products Exercises XXII. Henry Books Case
Notes and Main Ideas
Comprehensive Design Example
Chapter Outline
Notes and Main Ideas
I. Introduction II. Marvel College Requirements A. General Description B. Report Requirements C. Update (Transaction) Requirements III. Marvel College Information-Level Design IV. Final Information-Level Design V. Review Questions
Answers to Review Questions
1. (Changes on the Marvel College requirements)
a. Remove FacultyNum as a column in the Section table.
Create a separate table whose key is the concatenation
of SemesterCode, ScheduleCode, and FacultyNum. This new
table will have no other columns.
b. One solution would be to include MajorNum and
Description as columns in the Department table and
delete the Major table from the design. In the Advises
table, replace MajorNum with DepartmentNum. A second solution
would be to make DepartmentNum an alternate key within the Major
table and leave everything else as is.
c. Remove MajorNum from the Advises table and change the key to the
concatenation of StudentNum and FacultyNum.
d. Include the number of the faculty member who advises the student in
the Student table and delete the Advises table.
e. Designate the concatenation of LastName and FirstName as a secondary
key in within the Student table.
f. Remove OfficeNum from the Faculty table and create a new table whose key
is the concatenation of OfficeNum and FacultyNum.
g. Remove CreditsEarned and GradePoints from the StudentGrade table. (The
CreditsEarned for a course can be obtained by finding the number of credits
in the Course table for the given course provided the grade is a passing grade.)
h. Replace CourseNum with CourseCode in all tables. Remove DepartmentCode from any
table in which CourseCode appears other than the Course table itself. Although DepartmentCode
still appears in the Course table, it will no longer be part of the primary key. It will still
be a foreign key identifying the Department table, however.
i. Create a new table whose key is the concatenation of StudentNum, PrimaryCode, SemesterCode, and
AlternateCode. Remove AlternateCode from RegistrationRequest.
Holt Distributors Project Solution
General Comments:
Territory (TerritoryNum, TerritoryName)
Rep (RepNum, LastName, FirstName, Address, City, State, Zip, MTDSales,
YTDSales, MTDCommission, YTDCommission, CommissionRate, TerritoryNum)
FK TerritoryNum -> Territory
Customer (CustomerNum, CustomerName, Address1, Address2, City,
State, Zip, MTDSales, YTDSales, CurrentBalance, CreditLimit,
ShipName, ShipAddress1, ShipAddress2, ShipCity, ShipState,
ShipZip, RepNum)
FK RepNum -> Rep
Comment:
If the ship-to address fields are null for a particular customer, this customer has no special ship-to address. In this case, goods are to be shipped to the customer's regular address.
Part (PartNum, Description, UnitPrice, MTDSales, YTDSales,
OnHand, Allocated, ReorderPoint)
Vendor (VendorNum, VendorName, Address, City, State, Zip) VendorPart (VendorNum, PartNum, Price, MinimumOrderQuantity, ExpectedLeadTime) FK VendorNum -> Vendor FK PartNum -> Part
Orders (OrderNum, OrderDate, CustomerNum, CustomerPONum) FK CustomerNum -> Customer OrderDetail (OrderNum, SEQNum, PartNum, NumOrdered, QuotedPrice) FK OrderNum -> Orders FK PartNum -> Part
Comment:
You might ask how the design would differ if users are to be able to override the ship-to address for a customer on a particular order; i.e., the ship-to address for the order is allowed to be different from the ship-to address currently on file for the customer. In this case, the Orders table would also include ship-to fields. These must accept nulls, since they will not apply to each order. If on a given order the values are not null, they are understood to be the ship-to address. If they are null, the ship-to values from the Customer table are used instead.
Territory (TerritoryNum, TerritoryName)
Rep (RepNum, LastName, FirstName, Address, City, State, Zip, MTDSales,
YTDSales, MTDCommission, YTDCommission, CommissionRate, TerritoryNum)
FK TerritoryNum -> Territory
Customer (CustomerNum, CustomerName, $ddress1, Address2, City, State,
Zip, MTDSales, YTDSales, CurrentBalance, CreditLimit, ShipName,
ShipAddress1, ShipAddress2, ShipCity, ShipState, ShipZip, RepNum)
FK RepNum -> Rep
Part (PartNum, Description, UnitPrice, MTDSales, YTDSales,
OnHand, Allocated, ReorderPoint)
Vendor (VendorNum, VendorName, Address, City, State, Zip)
VendorPart (VendorNum, PartNum, Price, MinimumOrderQuantity, ExpectedLeadTime)
FK VendorNum -> Vendor
FK PartNum -> Part
Orders (OrderNum, OrderDate, CustomerNum, CustomerPONum)
FK CustomerNum -> Customer
OrderDetail (OrderNum, SEQNum, PartNum, NumOrdered, QuotedPrice)
FK OrderNum -> Orders
FK PartNum -> PartCustomer (CustomerNum, CurrentInvoiceTotal, ...) Orders (OrderNum, ...) OrderDetail (OrderNum, SEQNum, NumShipped, ...)
Note: Other fields in the Customer, Orders, and OrderDetail tables are already in the cumulative collection and will not add anything new.
Invoice(InvoiceNum, ShipDate, Freight, OrderNum, ShipStatus) FK OrderNum -> Orders InvoiceSummary (InvoiceNum, InvoiceDate, InvoiceTotal, Freight, CustomerNum) FK CustomerNum -> Customer
Comment:
Invoice records are created during the first phase of the invoicing cycle, when users are entering the numbers of the orders to release for invoicing. These records are used as invoices are printer, files are updated, and invoice summary records are created. Finally, as released orders are deleted from the database, these records are deleted also. Because of the limited life of these records and the relatively simple manner in which they are used, they are often kept external to the database in a simple flat file. In this case, deleting these records is accomplished by deleting the entire file. This is just an alternative approach we may keep in mind.Another thing worth paying attention to concerns the relationship, or, rather, the lack of a relationship between Invoice and InvoiceSummary. Both tables have the same primary key and yet they should not be combined. To appreciate the reason there is no relationship, you have to consider the sequence of events: an Invoicerecord is created that must match some order, the invoice is printed, files are updated, an InvoiceSummary record is created, and then the order and corresponding Invoice record are deleted. Thus, an Invoice record cannot be required to match an InvoiceSummary record since the InvoiceSummary record is created after the corresponding Invoice record. An InvoiceSummary record cannot be required to match an Invoice record, since the Invoice record will be deleted long before the InvoiceSummary record will. (InvoiceSummary records are not deleted until the end of the month.) For similar reasons the Invoice and InvoiceSummary tables cannot be combined. Note that if the Invoice information is kept outside of the database, we are not even faced with such an issue.
This is a good place to discuss about system-generated numbers, that is, users may wish to assign invoice numbers themselves or, what is actually more likely, they might prefer that the system automatically assigns these numbers. Assuming that the numbers are assigned sequentially, the system merely needs to store the last invoice number assigned. Then, when a new invoice is created, the system will retrieve this number, increment it by one giving the new invoice number, and then update the field containing the last number assigned with this new number. A natural question to raise at this point is: Where should this number be stored? Should it be a field in some special record in the database or in some separate file? It could actually go either place. If the number is only used by programs that access the database, placing it in the database is preferable. If other programs also use it, it is usually preferable to place it in a separate file.
Customer (CustomerNum, CurrentPaymentTotal, ...)
Note: Other fields in the Customer table are already in the cumulative collection and will not add anything new.
Payment (PaymentNum, CustomerNum, Payment Date, Amount) FK CustomerNum -> Customer
Comment: The same comment made concerning the system generating invoice numbers also applies to payment numbers.
Customer (CustomerNum, CustomerName, Address1, Address2, City,
State, Zip, CurrentBalance, CreditLimit, RepNum, CurrentInvoiceTotal,
CurrentPaymentTotal, CurrentAmount, Over30, Over60, Over90,
PreviousBalance)Territory (TerritoryNum, TerritoryName)
Rep (RepNum, LastName, FirstName, Address, City, State, Zip,
MTDSales, YTDSales, MTDCommission, YTDCommission,
CommissionRate, TerritoryNum)
FK TerritoryNum -> Territory
Customer (CustomerNum, CustomerName, Address1, Address2, City,
State, Zip, MTDSales, YTDSales, CurrentBalance,
CreditLimit, ShipName, ShipAddress1, ShipAddress2,
ShipCity, ShipState, ShipZip, CurrentInvoiceTotal,
CurrentPaymentTotal, CurrentAmount, Over30, Over60,
Over90, PreviousBalance, RepNum)
FK RepNum -> Rep
Part (PartNum, Description, UnitPrice, MTDSales, YTDSales,
OnHand, Allocated, ReorderPoint)
Vendor (VendorNum, VendorName, Address, City, State, Zip)
VendorPart (VendorNum, PartNum, Price, MinimumOrderQuantity,
ExpectedLeadTime)
FK VendorNum -> Vendor
FK PartNum -> Part
Orders (OrderNum, OrderDate, CustomerNum, CustomerPONum)
FK CustomerNum -> Customer
OrderDetail (OrderNum, SEQNum, PartNum, NumOrdered, QuotedPrice, NumShipped)
FK OrderNum -> Orders
FK PartNum -> Part
Invoice(InvoiceNum, ShipDate, Freight, OrderNum, ShipStatus)
FK OrderNum -> Orders
InvoiceSummary (InvoiceNum, InvoiceDate, InvoiceTotal, Freight, CustomerNum)
FK CustomerNum -> Customer
Payment (PaymentNum, CustomerNum, PaymentDate, Amount)
FK CustomerNum -> Customer
A114/I111