1 Design Methodology A structured approach that uses procedures, techniques, tools, and...
-
Upload
harry-richards -
Category
Documents
-
view
214 -
download
0
Transcript of 1 Design Methodology A structured approach that uses procedures, techniques, tools, and...
1
Design MethodologyA structured approach that uses procedures, techniques, tools, and
documentation aids to support and facilitate the process of design.
Three main phases 1. 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
2. Logical database design Mapping E-R Model to (relational) database schema Normalization
3. Physical database design
2
Mapping E-R Model to Relational Database Schema
1. Entity type Table schema
Composite Attributes
Multi-Value Attributes
2. How to maintain relationships?
Primary Key and Foreign Key
Many-to-Many
3
How to maintain relationships?
Foreign Key
Primary key of another relation (table)Representing relationship between two
relations (tables)
4
Foreign Key: Examples
Branch (Bno, Street, City, State, Zipcode, Phone) Staff (Sno, firstName, lastName, Address, Bno )
Owner (Ono, firstName, lastName, Phone (Multi-Value))PropertyForRent (Pno, Street, City, State, Zipcode, Ono)
Client (Cno, firstName, lastName, Phone, MaxRent, PrefType)Viewing (Cno, Pno, ViewDate, Comment)
5
How to Describe a Table Schema? Database Design Language (DBDL)
Branch (Bno, Street, City, State, Zipcode, Phone) PK: Bno AK: Street, City, Zipcode Phone FK: None
Viewing (Rno, Pno, ViewDate, Comment) PK: Rno, ViewDate AK: None FK: Rno references Client (Cno) Pno references Property
Multiple AK/FK on different lines!
Viewing (Rno, Pno, ViewDate, Comment) PK: Rno, ViewDate AK: None FK: Rno, Pno
FK: Rno references Client (Cno) Pno references Property
One FK! Not two!References!
6
Mapping Strong Entities to Relation (Table) Schemas
• Replacing composite attributes with simple attributes
• Adding new tables to remove multi-value attributes
7
Replacing Composite Attributes with Simple Attributes
Name: Composite (FirstName, LastName)
Use two atriibutes:
FirstName
LastName
Address : Compsite (Street, City, State, Zipcode)
Use four attributes:
Street
City
State
Zipcode
Performance issue
8
Composite Attributes
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 52001-1234
Search on state or zip code
9
Simple Attributes
staffNo firstName lastName Street City State zip
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 52001-1234
Search on state or zip code
10
Removing Multi-Value Attributes
No multi-value attributes in relational databases
First Order Logic
No sets as set elements
11
Multi-Value Attributes
branchNo street city state zipCode telNo
B001 1 main street
Platteville WI 53818 608-348-1234
608-348-3345
B002 15 university drive
Madison WI 53706 608-255-3034
608-255-1023
877-323-5678
… … … … … …
12
Removing Multi-Value Attributes without Losing Data
Entity Type in E-R ModelBranch branchNo . . . telNo: multi-value
How to Store telNo? phoneOne phoneTwo
(When we know the limit of phone numbers at a branch: at most two)
Staff staffNo homePhone workPhone cellPhone . . .
13
Each Branch Has at Most Three Phone Numbers
branchNo street . . . phone1 phone2 phone3
B001 1 main street
608-348-1234 608-348-3345
B002 15 university drive
608-255-3034 608-255-1023 877-323-5678
… … … … …
14
Home Phone, WorkPhone and Cell Phone
staffNo street . . . homePhone workPhone cellPhone
SL21 1 main street
608-348-1234 608-348-3345
SG37 15 university drive
608-255-3034 608-255-1023 877-323-5678
SA79 … … 608-255-3847
15
Multi-Value Attributes Without Limit
Entity Type in E-R ModelBranch branchNo . . . telNo: multi-value (NO LIMIT!)
More Examples
Student MajorWork Experience
Research publications . . .
16
Replacing Multi-Value Attributes
branchNo . . . telNo
B001 608-348-1234
608-348-3345
B002 608-255-3034
608-255-1023
877-323-5678
… … …
branchNo Street City State zipCode
B001
B002
…
branchNo telNo
B001 608-348-1234
B001 608-348-3345
B002 608-255-3034
B002 608-255-1023
B002 877-323-5678
… …One table two tablesMulti-Value attribute multiple recordsPrimary Key Foreign Key
17
Replacing Multi-Value Attributes
Entity Type in E-R ModelBranch branchNo . . . telNo: multi-value (NO LIMIT!)
How to Store telNo?Remove it from Branch and create a new table!
BranchPhone branchNo telPhone
What is the PK?Assumption: two branches don’t share the same phone #
Does it have a FK?
18
Mapping Entity Type to Table Schema
Entity Type in E-R ModelBranch branchNo address: composite (street, city, state, zipCode) telNo: multi-value (with or without limit!)
Table Schema (DBDL)
Branch (branchNo, street, city, state, zip) PK: branchNo AK: street, city, zip FK: NONE
BranchPhone (branchNo, telPhone) PK: telPhone AK: NONE FK: branchNo references Branch
19
Entity Type in E-R ModelStaff staffNo . . . DOB workExperince: multi-value Composite (start, end, org, position)
Store workExperince with staffNo in a new Table!WorkExperience staffNo start end org position
PK?Could create a new PK attribute (workExpID)
FK?
Mapping Entity Type to Table Schema
20
Storing Work ExperienceEntity 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: ? FK: staffNo references Staff
21
Design MethodologyA structured approach that uses procedures, techniques, tools, and
documentation aids to support and facilitate the process of design.
Three main phases 1. Conceptual database design Understanding client data E-R (EER) Model Contract between clients and designers E-R Model could be used for any database system
2. Logical database design Mapping E-R Model to (relational) database schema Normalization
3. Physical database design
22
Mapping E-R Model to Relational database schema (DBDL)
Branch (Bno, Street, City, State, Zipcode) PK: Bno AK: Street, City, Zipcode Phone FK: None
BranchPhone (branchNo, telPhone) PK: branchNo, telPhone AK: NONE FK: branchNo references Branch
Staff (Sno, firstName, lastName, Address, Bno ) PK: Sno AK: None FK: Bno references Branch
WorkExperience(staffNo, start, end, org, position) PK: staffNo, start, org AK: NONE FK: staffNo references Staff
No multi-value attributes, no composite attributes.