Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 All Powder Board and Ski SQL Server Workbook Chapter 2: Database Design Jerry Post Copyright © 2004.

Similar presentations


Presentation on theme: "1 All Powder Board and Ski SQL Server Workbook Chapter 2: Database Design Jerry Post Copyright © 2004."— Presentation transcript:

1 1 All Powder Board and Ski SQL Server Workbook Chapter 2: Database Design Jerry Post Copyright © 2004

2 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 3 SQL Server Data Types (Domains) NameDataBytes Text (characters) fixed variable national/Unicode memo char or nchar varchar nvarchar text or ntext 8000 bytes 2 gigabytes Fixed Variable Numeric Byte (8 bits) Integer (16 bits) Long (32 bits) (64 bits) Fixed precision Float Double Currency Yes/No tinyint smallint int bigint decimal(p,s) real float money bit 0 to 255 -2^15 to 2^15 -1 -2^31 to 2^31 -1 -2^63 to 2^63 -1 p: 1...38, s: 0...p 7 digits 15 digits 38 digits 0,1 1 2 4 8 15-17 4 4, 8 8 variable Date/Time Interval datetime, smalldatetime1/1/1753 to 12/31/9999 (3.33ms) 7/11/13 Imageimage2 gigabytesVariable See help file.

4 4 Initial Business Objects Employee EmployeeID TaxpayerID LastName FirstName Address City State ZIP Customer CustomerID LastName FirstName Phone Address City State ZIP Sale SaleID SaleDate CustomerID EmployeeID Rental RentID RentDate CustomerID ExpectedReturn

5 5 Associations or Relationships Employee EmployeeID TaxpayerID LastName FirstName Address City State ZIP Customer CustomerID LastName FirstName Phone Address City State ZIP Sale SaleID SaleDate CustomerID EmployeeID Rental RentID RentDate CustomerID ExpectedReturn 0…* 1…1

6 6 Action Browser: http://time-post.com/dbdesign New student who has two key numbers.

7 7 Getting Started Enter the key numbers you received Create a username and password. Enter your correct name, e-mail address and StudentID

8 8 Class Registration Successful account creation Select your university and class Enter the admit code

9 9 Action File/Open, choose All Powder case Right click/Add Table Right click header/Rename table Drag columns from right onto table Right click name/set data type

10 10 DBDesign: Example Available columns Menu Class (entity) Corrections Status line

11 11 Action Add Customer and Sale tables Add GenerateKey to Customer table Rename it to CustomerID Drag new CustomerID from right side into Sale table Drag CustomerID from Customer and drop it on CustomerID in Sale table Fill out relationship box

12 12 Relationships Drag-and- drop column Select min and max for both sides of the relationship

13 13 Action Choose Grade/Grade and Mark Double click messages in window Fix errors by removing columns and adding new tables

14 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 15 More Errors Try setting SKU as a key It still causes problems because SaleDate does not depend on the SKU

16 16 Split Many-to-Many Relationship Sale SaleID SaleDate CustomerID EmployeeID Inventory SKU Size QOH Many-to-Many SaleItem SaleID SKU QuantitySold SalePrice 1…1 0…* 1…* 1…1

17 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 cmItem: 181 cm

18 18 Action Create the SaleItem table Create the ItemModel table Include the proper columns Set the keys Set the data types Grade/Grade and Mark

19 19 Models and Items

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

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


Download ppt "1 All Powder Board and Ski SQL Server Workbook Chapter 2: Database Design Jerry Post Copyright © 2004."

Similar presentations


Ads by Google