Presentation is loading. Please wait.

Presentation is loading. Please wait.

All Powder Board and Ski Microsoft Access Workbook Chapter 3: Database Tables Jerry Post Copyright © 2003.

Similar presentations


Presentation on theme: "All Powder Board and Ski Microsoft Access Workbook Chapter 3: Database Tables Jerry Post Copyright © 2003."— Presentation transcript:

1 All Powder Board and Ski Microsoft Access Workbook Chapter 3: Database Tables Jerry Post Copyright © 2003

2 DBDesign: An Expert System http://time-post.com/dbdesign Benefits Makes it easy to create database diagrams Saves data in central location, so changes can be made from almost any computer Provides immediate detailed feedback on the design Requirements Instructors must ask for a free account Instructors and students need a Java-enabled Web browser

3 Identifying Key Columns If you are uncertain about which columns to key. Write them down and evaluate the business rules. OrderIDCustomerID For a given order, can there ever be more than one customer? If yes, then key CustomerID. In most businesses, only one customer per order, so do not key it. For a given customer, can there ever be more than one order? If yes, then key OrderID, otherwise, do not key it. All businesses hope to get more than one order from a customer, so OrderID must be key. Underline it. Since OrderID is the only key, these columns belong in the Order table. CustomerOrder(OrderID CustomerID, … )

4 AutoNumber

5 Customer Skill Level CustomerID, LastName, … Style, SkillLevel Business rule: Each customer can have one skill in many styles. Business rule: Each style can apply to more than one customer. Need a table with both attributes as keys. CustomerID, LastName, … Style, SkillLevel But you cannot include LastName, FirstName and so on, because then you would have to re-enter that data for each customer skill. Consider what happens if you (incorrectly) try to place Style and SkillLevel in the Customer table:

6 Customer Style Skills Customer CustomerID LastName FirstName Phone Address City State ZIP CustomerSkill CustomerID Style SkillLevel Style StyleDescription SkillLevel SkillDescription

7 Creating Tables in Access Primary key Data type Additional data type info Column name

8 Data Types: Subtypes Selected column Number data type Subtype: Single

9 Constraints Selected column Acceptable values Message

10 Simple Lookup Lists Selected column Combo box Value list Values in quotes and separated by commas Lookup tab

11 Database Table Lookup listAutoNumber generated

12 Define Relationships Relationship line Check all three boxes Add tables Drag column and drop Verify both columns

13 Create Tables with SQL CREATE TABLE Customer ( CustomerIDLong, LastNameText(50), FirstNameText(50), PhoneText(50), EmailText(150), AddressText(50), StateText(50), ZIPText(15), GenderText(15), DateOfBirthDate, CONSTRAINT pk_Customer PRIMARY KEY (CustomerID) )

14 Create Relationships with SQL CREATE TABLE Rental ( RentIDLong, RentDateDate, CustomerIDLong, ExpectedReturnDate, PaymentMethodText(50) CONSTRAINT pk_Rental PRIMARY KEY (RentID) CONSTRAINT fk_RentalCustomer FOREIGN KEY (CustomerID) REFERENCES Customer(CustomerID) ) ON DELETE CASCADE ON UPDATE CASCADE Note: ON DELETE AND ON UPDATE are not supported with Access 2002, but hopefully will be supported with 2003.

15 Estimating Database Size CustomerIDLong4 LastNameText(50)30 FirstNameText(50)20 PhoneText(50)24 EmailText(150)50 AddressText(50)50 StateText(50)2 ZIPText(15)14 GenderText(15)10 DateOfBirthDate8 Average bytes per customer212 Customers per week (winter)*200 Weeks (winter)*25 Bytes added per year1,060,000

16 Data Assumptions 200 customers per week for 25 weeks 2 skills per customer 2 rentals per customer per year 3 items per rental 20 percent of customers buy items 4 items per sale 100 manufacturers 20 models per manufacturer 5 items (sizes) per model

17 Database Table Sizes


Download ppt "All Powder Board and Ski Microsoft Access Workbook Chapter 3: Database Tables Jerry Post Copyright © 2003."

Similar presentations


Ads by Google