Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 3630 Database Design and Implementation

Similar presentations


Presentation on theme: "CS 3630 Database Design and Implementation"— Presentation transcript:

1 CS 3630 Database Design and Implementation

2 Design Methodology Three main phases
A structured approach that uses procedures, techniques, tools, and documentation aids to support and facilitate the process of design. Three main phases Conceptual database design Understanding client data E-R (EER) Model Agreement between clients and designers E-R Model could be used for any database system Logical database design Mapping E-R Model to (relational) database schema Normalization Physical database design 2013: Finished at 43 for both sections

3 Mapping E-R Model to Relational Database Schema
Entity type  Table schema How to maintain relationships?

4 Mapping Strong Entities to Relation (Table) Schemas
Replacing composite attributes with simple attributes Adding new tables to remove multi-value attributes

5 Replacing Composite Attributes with Simple Attributes
Name: Composite (FirstName, LastName) Use two attributes: FirstName LastName Address : Composite (Street, City, State, Zipcode) Use four attributes: Street City State Zipcode Performance issue

6 Composite Attributes Search/Project on state or zip code staffNo Name
Address . . . SL21 John White 1 main street, Platteville, WI 53818 SG37 Ann Beech 15 University Dr, Madison, WI 53706 SA9 Mary Howe 908 Western avenue, Dubuque, IA Search/Project on state or zip code

7 Simple Attributes Search/Project on state or zip code staffNo
firstName lastName Street City State zip SL21 John White 1 main street Platteville WI 53818 SG37 Ann Beech 15 University Dr Madison 53706 SA9 Mary Howe 908 Western avenue Dubuque IA Search/Project on state or zip code

8 E-R Model Staff StaffNo Name: Simple or Composite? Address Salary . . .

9 Removing Multi-Value Attributes
No multi-value attributes in relational databases First Order Logic No sets as set elements

10 Multi-Value Attributes
branchNo street city state zipCode telNo B001 1 main street Platteville WI 53818 B002 15 university drive Madison 53706

11 Removing Multi-Value Attributes without Losing Data
Entity Type in E-R Model Branch branchNo . . . telNo: multi-value How to Store telNo? phoneOne phoneTwo phoneThree (When we know the limit of phone numbers at a branch: at most three) Staff staffNo homePhone workPhone cellPhone

12 Each Branch Has at Most Three Phone Numbers
branchNo street . . . phone1 phone2 phone3 B001 1 main street B002 15 university drive

13 Home Phone, WorkPhone and Cell Phone
staffNo street . . . homePhone workPhone cellPhone SL21 1 main street SG37 15 university drive SA79

14 Multi-Value Attributes Without Limit
Entity Type in E-R Model Branch branchNo . . . telNo: multi-value (NO LIMIT or LIMIT TOO LARGE) More Examples Student Major Work Experience Research publications

15 Replacing Multi-Value Attributes
branchNo Street City State zipCode B001 B002 branchNo . . . telNo B001 B002 branchNo telNo B001 B002 One table  two tables Multi-Value attribute  multiple records Primary Key  Foreign Key

16 Replacing Multi-Value Attributes
Entity Type in E-R Model Branch branchNo . . . telNo: multi-value (NO LIMIT!) How to Store telNo? Remove it from Branch and create a new table! BranchPhone telPhone Which attributes should be in the new table? The PK attribute(s) and the multi-value attribute. Is branchNo the PK in Branch? Is branchNo the PK in BranchPhone? Foreign Key!

17 Primary Key and Foreign Key
branchNo telNo B001 B002 branchNo Street City State zipCode B001 B002

18 What is the Primary Key? BranchPhone branchNo telPhone Assumption
Two branches don’t share the same phone # Two branch can shared the same phone # (branchNo, telephone) newAtt Must be unique!

19 Replacing Multi-Value Attributes
Always use a new table to replace any multi-value attribute IN Assignments Quizzes Tests Final

20 Mapping Entity Type to Table Schema
Entity Type in E-R Model Branch branchNo address: composite (street, city, state, zipCode) telNo: multi-value (with or without limit!) Table Schema (DBDL) Branch (branchNo, street, city, state, zipCode) PK: branchNo AK: street, city, state, zipCode FK: NONE BranchPhone (newAtt, branchNo, telPhone) PK: newAtt AK: NONE FK: branchNo references Branch

21 Mapping Entity Type to Table Schema
Entity Type in E-R Model Staff staffNo . . . DOB workExperince: multi-value Composite (start, end, org, position) Store workExperince with staffNo in a new Table! WorkExperience start end org position PK? Could create a new PK attribute (workExpID) FK?

22 Storing Work Experience
Entity Type in E-R Model Staff staffNo . . . DOB workExperince: multi-value Composite (start, end, org, position) Table Schema (DBDL) Staff (staffNo, . . ., DOB) PK: staffNo AK: NONE FK: NONE WorkExperience(workExpID, staffNo, start, end, org, position) PK: workExpID AK: None FK: staffNo references Staff

23 Individual Assignment Due Wednesday, Feb 22


Download ppt "CS 3630 Database Design and Implementation"

Similar presentations


Ads by Google