1 all powder board and ski sql server workbook chapter 2: database design jerry post copyright ©...
TRANSCRIPT
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
SQL Server Data Types (Domains)Name Data Bytes
Text (characters) fixed variable national/Unicode memo
char or ncharvarcharnvarchartext or ntext
8000 bytes8000 bytes8000 bytes2 gigabytes
FixedVariableVariableVariable
Numeric Byte (8 bits) Integer (16 bits) Long (32 bits) (64 bits) Fixed precision Float Double Currency Yes/No
tinyintsmallintintbigintdecimal(p,s)realfloatmoneybit
0 to 255-2^15 to 2^15 -1-2^31 to 2^31 -1-2^63 to 2^63 -1p: 1...38, s: 0...p7 digits15 digits38 digits0,1
124815-1744, 88variable
Date/TimeInterval
datetime, smalldatetime 1/1/1753 to 12/31/9999 (3.33ms)
7/11/13
Image image 2 gigabytes Variable
See help file.
4
Initial Business Objects
Employee
EmployeeIDTaxpayerIDLastNameFirstNameAddressCityStateZIP
Customer
CustomerIDLastNameFirstNamePhoneAddressCityStateZIP
Sale
SaleIDSaleDateCustomerIDEmployeeID
Rental
RentIDRentDateCustomerIDExpectedReturn
5
Associations or Relationships
Employee
EmployeeIDTaxpayerIDLastNameFirstNameAddressCityStateZIP
Customer
CustomerIDLastNameFirstNamePhoneAddressCityStateZIP
Sale
SaleIDSaleDateCustomerIDEmployeeID
Rental
RentIDRentDateCustomerIDExpectedReturn
0…*
1…1
7
Getting Started
Enter the key numbers you received
Create a username and password.
Enter your correct name, e-mail address and StudentID
8
Class Registration
Successful account creation
Select your university and class
Enter the admit code
9
Action
ActionFile/Open, choose All Powder caseRight click/Add TableRight click header/Rename tableDrag columns from right onto tableRight click name/set data type
11
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
13
Action
ActionChoose Grade/Grade and MarkDouble click messages in windowFix errors by removing columns and adding new tables
14
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
15
More Errors
Try setting SKU as a key
It still causes problems because SaleDate does not depend on the SKU
16
Split Many-to-Many Relationship
Sale
SaleIDSaleDateCustomerIDEmployeeID
Inventory
SKUSizeQOH
Many-to-Many
SaleItem
SaleIDSKUQuantitySoldSalePrice
1…1
0…*
1…*
1…1
17
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
18
Action
ActionCreate the SaleItem tableCreate the ItemModel tableInclude the proper columnsSet the keysSet the data typesGrade/Grade and Mark
20
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.