Lesson 3: Table Design and Key Relationships
Try This: Do the following steps
1. Open the Brown Bag Lunch database you
have been working on.
Or, you may download
BBL Adv ver3.accdb.
2. Create a new Receipt Table, tblReceipt
In Design View add the following Fields:
Field Name: ReceiptID, Data Type: AutoNumber.
Field Name: CustomerID, Data Type: Number (Long Integer).
Field Name: Date, Data Type: Date/Time.
Make ReceiptID the Primary Key. Make the
Default Value for the Date/Time =Now(). Format the Date as Medium.
Save the
Table and name it tblReceipt. Close this Table.
3. Create a new Table for the products
sold, tblReceiptProducts. In Design View add the following Fields:
Field Name: ReceiptProductsID, Data Type: AutoNumber.
Field Name: ReceiptD, Data Type: Number (Long Integer).
Field Name: DateReceipt, Data Type: Date/Time.
Field Name: CustomerID, Data Type: Number (Long Integer).
Field Name: ProductID, Data Type: Number (Long Integer).
Field Name: Memo, Data Type: Memo.
Make ReceiptProductsID the Primary Key.
Save the Table and name it tblReceiptProducts. Close this Table.
4. Use the command Database
Tools->Relationships to document the database with the Relationship
Tools. Add the following Tables: tblReceipt, tblReceiptProducts,
tblProducts.
5. Create a JOIN from ReceiptID in
tblReceipt to ReceiptID in tblReceiptProducts. Enforce Referential
Integrity.
6. Create a JOIN from ProductID in
tblReceiptProducts to ProductID in tblProducts. Enforce Referential
Integrity.
7. Add the Customers Table. Create a JOIN
from CustomerID in tblReceipt to CustomerID in tblCustomers. Enforce
Referential Integrity.
8. Save and close the Relationship Window.
9. Close the Brown Bag Lunch database.