The following is a list of the tables obtained from the ERD-to-Tables process described in the notes and in the description of part 2.
Item Hierarchy : This is a total disjoint hierarchy. We should check if we can keep one level and not the other. Item and Book participate in different associations. Therefore we need to keep both levels of the hierarchy:
Item (upc, taxable, selling_price, stock, item_type)
Nonbook (upc, name, category, manufacturer)
Book (upc, title, publisher, category)
Author (name)
HasAuthor (upc, name)
Text (upc)
Course (dept, course#)
UsedIn (upc, dept, course#)
Supplier (name, address, city, status)
Supplies (name, upc, sup_price)
Account (id, holder, dept, amount)
Transaction Hierarchy : This is a total disjoint hierarchy. We should check if we can discard any level. Entity set transaction does not participate in any relationship. Therefore we can discard it. Similarly, the entity sets purchase and return can be discarded and keep the lower level sets, as long as we are certain that each query for such a transaction will always specify the type of the transaction (i.e. cash, card, or account). On the other hand, if we expect queries that refer to just a purchase or a return without specifying the type, we should keep the purchase and return tables and discard the lower tables. Therefore the tables for this hierarchy would be as following:
Shipment (tid, date, name, upc, quantity)
1st
Approach for Purchase/Return:
Assume that every query
about the a purchase or return transaction will always specify the type of the
transaction (i.e. cash, card, or account). So, we keep the lower tables and
discard the higher ones:
CashPurchase (tid, date, upc, quantity, amount, receiptId)
CardPurchase (tid, date, upc, quantity, amount, card_type, card#, receiptId)
AccountPurchase (tid, date, upc, quantity, amount, type, id, receiptId)
CashReturn (tid, date, upc, quantity, amount, purchase_tid)
CardReturn (tid, date, upc, quantity, amount, card_type, card#, purchase_tid)
AccountReturn (tid, date, upc, quantity, amount, id, purchase_tid)
2nd Approach for Purchase/Return: Assume
that most queries about the a purchase
or return transaction will not specify the type of the transaction (i.e. cash,
card, or account). So, we keep the higher tables and discard the lower ones.
Attributes pur_type to distinguish the cash, the card and the account type of
purchase. Her is an idea :
Purchase (tid, date, upc, quantity, amount, pur_type, id, receiptId)
Return (tid, date, upc, quantity, amount, pur_type, id, purchase_tid)
There are three source of the functional dependencies:
The following is a list of FD's identified from the ER diagram for the UBStore enterprise for each table. We take the 2nd approach for Purchase/Return.
Item (upc, taxable, selling_price, stock, item_type)
Nonbook (upc, name, category, manufacturer)
Book (upc, title, publisher, category)
Text (upc)
Author (name)
HasAuthor (upc, name)
Course (dept, course#)
UsedIn (upc, dept, course#)
Supplier (name, address, city, status)
Supplies (name, upc, sup_price)
Account (id, holder, dept, amount)
Purchase (tid, date, upc, quantity, amount, pur_type, id, receiptId)
Return (tid, date, upc, quantity, amount, pur_type, id, purchase_tid)
Shipment (tid, date, name, upc, quantity)
We observe that in all table of part (1) except Supplier, Supplies, and Account the dependencies are key dependencies. Therefore all tables except those three are in BCNF .
The extra dependency (AFD3) in Supplier is implied by the key dependency. The LHS of (AFD3) includes the key. Therefore Supplier is in BCNF.
Supplies is not in BCNF. We need to split it into
Similarly, Account is not in BCNF.
We need to split it into
Now, we must check ( using the problem statement) whether there is information in the tables that it is not needed. By checking the UBStore problem description we conclude the following:
1. We never insert any author without the book they author. Therefore the author table is not needed. We can get all the information about authors from the HasAthor table. Therefore the Author table is deleted.
2. Similarly, we don’t keep information about courses, unless they have a text assigned (we never insert or delete courses alone). The used-in relation is total on text. This means that we will never keep a text if it is not used in a course. Moreover, text has not any additional attributes. Therefore we can delete the tables Text and Course and retain only the UsedIn table that contains all the information about the texts and the courses in which they are used.
3. Combine tables with the same keys when this action does not introduce redundancies. In our case, tables Item and ProductPrice can be combined into:
Item (upc, taxable, selling_price, stock, item_type, sup_price)
4. OPTIONAL: If we want our Item table to be more efficient we can combine item, book and nonbook into one table as following:
a. Add to Item an attribute category with values "book", "equipment", software", "arts", or "misc". This includes all the categories of nonbook items.
b. Add to Item attributes name and producer. For a nonbook, these attributes will represent the name and the manufacturer of the item. For a book, these attributes will represent the title and the publisher of the book.
c. Now we can delete the tables Nonbook and Book and keep the new Item table.