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 © 2007.

Similar presentations

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

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

2 DBDesign: An Expert System 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 Action Create Customer table in Design view Enter column names Select data types Assign the primary key Save the table

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

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

10 Action Select the Gender column Validation rule: Female Or Male Or Unidentified Validation text: Please enter Female, Male, or Unidentified

11 Constraints Selected column Acceptable values Message

12 Action Select the Gender column Select the Lookup tab Display Control: Combo Box Row Source Type: Value List Row Source: Female;Male;Unidentified Switch to datasheet view and test it

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

14 Database Table Lookup listAutoNumber generated

15 Action Tools/Relationships (or button) Add all tables Move and resize them to fit Drag and drop key columns on foreign keys Check integrity and cascade boxes Define all relationships

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

17 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) )

18 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.

19 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

20 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

21 Action Create a spreadsheet Enter table names as rows Add columns for: Bytes, Rows, Totals Calculate the bytes per table row Estimate the number of rows Compute the table and overall totals

22 Database Table Sizes

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

Similar presentations

Ads by Google