21
All Powder Board and Ski Microsoft Access Workbook Chapter 2: Database Design Jerry Post Copyright © 2007

All Powder Board and Ski Microsoft Access Workbook Chapter 2: Database Design Jerry Post Copyright © 2007

Embed Size (px)

Citation preview

Page 1: All Powder Board and Ski Microsoft Access Workbook Chapter 2: Database Design Jerry Post Copyright © 2007

All Powder Board and Ski

Microsoft Access WorkbookChapter 2: Database DesignJerry PostCopyright © 2007

Page 2: All Powder Board and Ski Microsoft Access Workbook Chapter 2: Database Design Jerry Post Copyright © 2007

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

Page 3: All Powder Board and Ski Microsoft Access Workbook Chapter 2: Database Design Jerry Post Copyright © 2007

Access Data Types (Domains)Name Data Bytes

Text (characters) fixed variable memo

NATextMemo

255 64 K

VariableVariable

Numeric Byte (8 bits) Integer (16 bits) Long (32 bits) (64 bits) Fixed precision Float Double Currency Yes/No

Number: ByteNumber: IntegerNumber: Long IntegerNANumber: DecimalNumber: SingleNumber: DoubleCurrencyYes/No

0-255+/- 32767+/- 2 billion+/- 1 E 28+/- 1 E 38+/- 1 E 308+/- 900.0000 trillion0/1

124124881 bit

Date/Time Date/Time 1/1/100 – 12/31/9999 (1 sec) 8

Image OLE Object 1 gigabyte Variable

AutoNumber AutoNumber Long (+/- 2 billion) 4

Page 4: All Powder Board and Ski Microsoft Access Workbook Chapter 2: Database Design Jerry Post Copyright © 2007

Initial Business Objects

Employee

EmployeeIDTaxpayerIDLastNameFirstNameAddressCityStateZIP

Customer

CustomerIDLastNameFirstNamePhoneAddressCityStateZIP

Sale

SaleIDSaleDateCustomerIDEmployeeID

Rental

RentIDRentDateCustomerIDExpectedReturn

Page 5: All Powder Board and Ski Microsoft Access Workbook Chapter 2: Database Design Jerry Post Copyright © 2007

Associations or Relationships

Employee

EmployeeIDTaxpayerIDLastNameFirstNameAddressCityStateZIP

Customer

CustomerIDLastNameFirstNamePhoneAddressCityStateZIP

Sale

SaleIDSaleDateCustomerIDEmployeeID

Rental

RentIDRentDateCustomerIDExpectedReturn

0…*

1…1

Page 6: All Powder Board and Ski Microsoft Access Workbook Chapter 2: Database Design Jerry Post Copyright © 2007

Action

ActionBrowser: http://time-post.com/dbdesignNew student who has two key numbers.

Page 7: All Powder Board and Ski Microsoft Access Workbook Chapter 2: Database Design Jerry Post Copyright © 2007

Getting Started

Enter the key numbers you received

Create a username and password.

Enter your correct name, e-mail address and StudentID

Page 8: All Powder Board and Ski Microsoft Access Workbook Chapter 2: Database Design Jerry Post Copyright © 2007

Class Registration

Successful account creation

Select your university and class

Enter the admit code

Page 9: All Powder Board and Ski Microsoft Access Workbook Chapter 2: Database Design Jerry Post Copyright © 2007

Action

ActionFile/Open, choose All Powder caseRight click/Add TableRight click header/Rename tableDrag columns from right onto tableRight click name/set data type

Page 10: All Powder Board and Ski Microsoft Access Workbook Chapter 2: Database Design Jerry Post Copyright © 2007

DBDesign: Example

Available columns

Menu

Class(entity)

Corrections

Status line

Page 11: All Powder Board and Ski Microsoft Access Workbook Chapter 2: Database Design Jerry Post Copyright © 2007

Action

ActionAdd Customer and Sale tablesAdd GenerateKey to Customer tableRename it to CustomerIDDrag new CustomerID from right side into Sale tableDrag CustomerID from Customer and drop it on

CustomerID in Sale tableFill out relationship box

Page 12: All Powder Board and Ski Microsoft Access Workbook Chapter 2: Database Design Jerry Post Copyright © 2007

Relationships

Drag-and-drop column

Select min and max for both sides of the relationship

Page 13: All Powder Board and Ski Microsoft Access Workbook Chapter 2: Database Design Jerry Post Copyright © 2007

Action

ActionChoose Grade/Grade and MarkDouble click messages in windowFix errors by removing columns and adding new tables

Page 14: All Powder Board and Ski Microsoft Access Workbook Chapter 2: Database Design Jerry Post Copyright © 2007

Design Errors

Add SKU to the Sale table

Connect the Inventory table to the Sale table

Double click the diagnostic message

Possible errors are highlighted

Page 15: All Powder Board and Ski Microsoft Access Workbook Chapter 2: Database Design Jerry Post Copyright © 2007

More Errors

Try setting SKU as a key

It still causes problems because SaleDate does not depend on the SKU

Page 16: All Powder Board and Ski Microsoft Access Workbook Chapter 2: Database Design Jerry Post Copyright © 2007

Split Many-to-Many Relationship

Sale

SaleIDSaleDateCustomerIDEmployeeID

Inventory

SKUSizeQOH

Many-to-Many

SaleItem

SaleIDSKUQuantitySoldSalePrice

1…1

0…*

1…*

1…1

Page 17: All Powder Board and Ski Microsoft Access Workbook Chapter 2: Database Design Jerry Post Copyright © 2007

Ski Shop Inventory

Photo: www.rossignol.com

Ski shops carry multiple lengths of each ski or board model.

Model information refers to the overall type of board or ski.

Inventory information refers to an individual ski or board—defined by its length.

Model:Rossignol Axium

Item: 196 cm Item: 181 cm

Page 18: All Powder Board and Ski Microsoft Access Workbook Chapter 2: Database Design Jerry Post Copyright © 2007

Action

ActionCreate the SaleItem tableCreate the ItemModel tableInclude the proper columnsSet the keysSet the data typesGrade/Grade and Mark

Page 19: All Powder Board and Ski Microsoft Access Workbook Chapter 2: Database Design Jerry Post Copyright © 2007

Models and Items

Page 20: All Powder Board and Ski Microsoft Access Workbook Chapter 2: Database Design Jerry Post Copyright © 2007

Customer Skill Level

CustomerID, LastName, … Style, SkillLevel

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.

Page 21: All Powder Board and Ski Microsoft Access Workbook Chapter 2: Database Design Jerry Post Copyright © 2007

Customer Style Skills

Customer

CustomerIDLastNameFirstNamePhoneAddressCityStateZIP

CustomerSkill

CustomerIDStyleSkillLevel

Style

StyleStyleDescription

SkillLevel

SkillLevelSkillDescription