14.01.2015 Views

Usage of Weak Entities An Example of Ternary Relationship ...

Usage of Weak Entities An Example of Ternary Relationship ...

Usage of Weak Entities An Example of Ternary Relationship ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

¡¦¥¦¡¤§ ¨©¡¦ ¡¦¨¨¦£<br />

¢¡¤£<br />

¢¢¢¦¤<br />

<br />

7¦9¦7¤: ;;;¦=8<br />

6¢7¤8<br />

C¢DC¢E¢F¦G@GF¤HIJ<br />

@AB<br />

a¦c¦a¤d efa¦g a¦heie¦gb<br />

`¢a¤b<br />

m¢nm¢o¢p¦qjqp¤rst<br />

jkl<br />

"¦$¦"¤% &'"¦( "¦)&*&¦(#<br />

!¢"¤#<br />

.¢/.¢0¢1¦2+21¤345<br />

+,-<br />

L¦N¦L¤O PQL¦R L¦SPTP¦RM<br />

K¢L¤M<br />

X¢YX¢Z¢[¦\U\[¤]^_<br />

UVW<br />

v¦x¦v¤y z{v¦| v¦}z~z¦|w<br />

u¢v¤w<br />

‚¢ƒ‚¢„¢…¦††…¤‡ˆ‰<br />

€<br />

<strong>Usage</strong> <strong>of</strong> <strong>Weak</strong> <strong>Entities</strong><br />

Database Modeling Using the Entity-<br />

<strong>Relationship</strong> Model<br />

(Continued)<br />

• <strong>Weak</strong> Entity can be used when converting a<br />

n-ary relationship to a number <strong>of</strong> binary<br />

relationships.<br />

• The basic algorithm can be found in the<br />

previous lecture note.<br />

• The additional ENTITY CLASS is actually<br />

a weak entity.<br />

<strong>An</strong> <strong>Example</strong> <strong>of</strong> <strong>Ternary</strong> <strong>Relationship</strong><br />

Converted E-R Diagram<br />

SName<br />

Quantity<br />

ProjName<br />

SName<br />

Quantity<br />

ProjName<br />

SUPPLIER<br />

SUPPLY<br />

PROJECT<br />

SUPPLIER<br />

1 N N 1<br />

SS SUPPLY SPJ<br />

PROJECT<br />

N<br />

SP<br />

PART<br />

PartNo<br />

1<br />

PART<br />

PartNo<br />

What if defining a cardinality constraint<br />

Converted E-R Diagram<br />

SName<br />

Quantity<br />

ProjName<br />

SName<br />

Quantity<br />

ProjName<br />

SUPPLIER<br />

1 M<br />

SUPPLY<br />

PROJECT<br />

SUPPLIER<br />

1 1 N 1<br />

SS SUPPLY SPJ<br />

PROJECT<br />

N<br />

N<br />

SP<br />

PART<br />

PartNo<br />

1<br />

PART<br />

PartNo<br />

1


‹¦¦‹¤Ž ‹¦‘ ‹¦’“¦‘Œ<br />

Š¢‹¤Œ<br />

—¢˜—¢¢š¦›”›š¤œž<br />

”•–<br />

µ¦·¦µ¤¸ ¹ºµ¦» µ¦¼¹½¹¦»<br />

´¢µ¤<br />

Á¢ÂÁ¢Ã¢Ä¦Å¾ÅĤÆÇÈ<br />

¾¿À<br />

ߦá¦ß¤â ãäߦå ߦæãçã¦åà<br />

ޢߤà<br />

ë¢ìë¢í¢î¦ïèïî¤ðñò<br />

èéê<br />

¤¡ ¦¢¦ ¤£ ¤¥ ¦ ¦§¤¨¤ ¦¡<br />

Ÿ¢<br />

¬¢­¬¢®¢¯¦°©°¯¤±²³<br />

©ª«<br />

Ê¦Ì¦Ê¤Í ÎÏʦРʦÑÎÒΦÐË<br />

ɢʤË<br />

Ö¢×֢آ٦ÚÓÚÙ¤ÛÜÝ<br />

ÓÔÕ<br />

ô¦ö¦ô¤÷ øùô¦ú ô¦ûøüø¦úõ<br />

ó¢ô¤õ<br />

¢¡£ ¢¤¢¥§¦ý¨¦©¥££<br />

ýþÿ<br />

Design Principles<br />

• Faithfulness<br />

• Avoiding redundancy<br />

• Keep it simple<br />

• Picking the right kind <strong>of</strong> element<br />

Faithfulness<br />

• Include everything needs to be described.<br />

• Avoid meaningless descriptions.<br />

• Enforce as many constraints as possible.<br />

– Cardinality Ratios.<br />

– Participation Constraints<br />

– Existence Dependency.<br />

Cardinality Ratios<br />

• The cardinality ratios for binary relationships<br />

– 1:1, 1:N, N:1, and M:N<br />

• Attributes <strong>of</strong> 1:1 relationship types can be migrated<br />

to either <strong>of</strong> the participating entity types.<br />

• Attributes <strong>of</strong> 1:N or N:1 relationship types can be<br />

migrated only to the entity type at N-side <strong>of</strong> the<br />

relationship.<br />

• Attributes <strong>of</strong> M:N relationship types must be<br />

specified as relationship attributes.<br />

EMPLOYEE<br />

Starting date<br />

EMPLOYEE<br />

EMPLOYEE<br />

<strong>Example</strong>s<br />

Manages<br />

1 1<br />

Starting date<br />

Manages<br />

1 1<br />

Manages<br />

1 1<br />

DEPARTMENT<br />

DEPARTMENT<br />

DEPARTMENT<br />

Starting date<br />

<strong>Example</strong>s<br />

<strong>Example</strong>s<br />

EMPLOYEE<br />

Hours<br />

N<br />

Works_on<br />

1<br />

Hours<br />

PROJECT<br />

EMPLOYEE<br />

M<br />

Works_on<br />

N<br />

PROJECT<br />

EMPLOYEE<br />

N<br />

Works_on<br />

1<br />

PROJECT<br />

Hours<br />

Note:<br />

IF we assumed that each employee can only work on one project, and there<br />

may be many employees working on the same project, THEN:<br />

The attribute Hours can be migrated to EMPLOYEE, but not PROJECT.<br />

Note:<br />

IF we assume that each employee may work on multiple projects at<br />

the same time, and there may be many employees working on the<br />

same projects, THEN:<br />

The attribute Hours can not be migrated to either PROJECT or<br />

EMPLOYEE.<br />

2


§§ § §£§<br />

¢<br />

¢!£ ¢"¢#§$%¨$©#&£'£(<br />

¨<br />

§A§B CD§E §FC£GC§E@<br />

>¢@<br />

IJ K¢L£K¢M¢N§O%Ḧ O©NP£Q£R<br />

Ḧ<br />

i§k§il mni§o i§pm£qm§oj<br />

h¢ij<br />

u¢v£u¢w¢x§y%r¨y©xz£{£|<br />

r¨st<br />

*§,§*- ./*§0 *§1.£2.§0+<br />

)¢*+<br />

6¢7£6¢8¢9§:%3¨:©9;£


“§•§“– —˜“§ “§š—£›—§”<br />

’¢“”<br />

Ÿ¢ £Ÿ¢¡ ¢§£%œ¨£©¢¤£¥£¦<br />

œ¨ž<br />

½§¿§½À Á½§Ã ½§ÄÁ£ÅÁ§Ã¾<br />

¼¢½¾<br />

ɢʣɢˢ̧Í%ƨͩÌΣϣÐ<br />

ƨÇÈ<br />

ç§é§çê ëìç§í ç§îë£ïë§íè<br />

æ¢çè<br />

ó¢ô£ó¢õ¢ö§÷%ð¨÷©öø£ù£ú<br />

ð¨ñò<br />

¨§ª§¨« ¬­¨§® ¨§¯¬£°¬§®©<br />

§¢¨©<br />

´¢µ£´¢¢·§¸%±¨¸©·¹£º£»<br />

±¨²³<br />

Ò§Ô§ÒÕ Ö×Ò§Ø Ò§ÙÖ£ÚÖ§ØÓ<br />

Ñ¢ÒÓ<br />

ޢߣޢà¢á§â%Û¨â©áã£ä£å<br />

Û¨ÜÝ<br />

EMPLOYEE<br />

<strong>Example</strong>s<br />

(0,1) (1,1)<br />

Manages<br />

DEPARTMENT<br />

EMPLOYEE<br />

(0,N)<br />

<strong>Example</strong>s<br />

Dependents_<strong>of</strong><br />

What does this example imply<br />

1 Manages 1<br />

SSN<br />

DEPENDENT<br />

(1,1)<br />

EMPLOYEE<br />

What does this example imply<br />

DEPARTMENT<br />

name sex birthdate relationship<br />

What does this example imply<br />

Avoiding Redundancy<br />

<strong>Example</strong>s<br />

• Problem with redundancy<br />

– Wastes space.<br />

– Encourages inconsistency.<br />

• Principle: describe and store everything<br />

once only.<br />

• Intuition: something is redundant if it could<br />

be hidden from view, and you could still<br />

figure out what it is from the other data.<br />

name<br />

BEERS<br />

ManfBy<br />

name<br />

manf<br />

BEERS<br />

manfadd<br />

Question: Which one is better<br />

name<br />

MANFS<br />

address<br />

KISS: Keep It Simple, Student<br />

• Avoid intermediate concepts if unnecessary.<br />

name<br />

BEERS<br />

ManfBy<br />

name<br />

MANFS<br />

4

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!