52
D r. Ka l p a ki s CMSC 461, Database Management Systems http://www.csee.umbc.edu/~kalpakis/Courses/461  Entity-Relationship odel 

Entity Relations Model

Embed Size (px)

Citation preview

Page 1: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 1/52

Dr. Kalpakis

CMSC 461, Database Management Systems

http://www.csee.umbc.edu/~kalpakis/Courses/461

 Entity-Relationship odel 

Page 2: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 2/52

CMSC 461- Dr. Kalpakis 

2

!utline

Entity Sets

Relationship Sets

Design Issues

Mapping Constraints

Keys

E-R Diagram

Extene E-R !eatures

Design o" an E-R Database S#hema

Reu#tion o" an E-R S#hema to $ables

Page 3: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 3/52

CMSC 461- Dr. Kalpakis 

3

 Entity "ets

% database #an be moele as a #olle#tion o" entities, an

relationships among those entities&

%n entity is an ob'e#t that exists an is istinguishable "rom

other ob'e#ts&

Entities ha(e attributes

%n entity set  is a set o" entities o" the same type that share the

same properties&

Page 4: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 4/52

CMSC 461- Dr. Kalpakis 

4

 #ttributes

%n entity is represente by a set o" attributes, i&e& es#ripti(e

 properties possesse by all members o" an entity set&

 $omain ) the set o" permitte (alues "or ea#h attribute%ttribute types*

"imple an composite attributes +that #an be "urther i(ie in

#omponent attributes&

"in%le-&alued  an multi-&alued  attributes $eri&ed  attributes

Can be #ompute "rom other attributes

E&g& a%e, gi(en ate o" birth

customer = (customer-id, customer-name, customer-street, customer-city)

loan = (loan-number, amount)

Page 5: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 5/52

CMSC 461- Dr. Kalpakis 

5

Composite #ttributes

Page 6: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 6/52

CMSC 461- Dr. Kalpakis 

6

 Relationship "ets

% relationship is an asso#iation among se(eral entities

% relationship set is a mathemati#al relation among n ≥ 

entities, ea#h ta.en "rom entity sets

/+e1, e-, 0 en e1  ∈  E 1, e- ∈  E -, 0, e

n ∈  E 

n2

3here +e1, e-, 0, en is a relationship

a relationship set #an ha(e asso#iate attributeseg, the depositor relationship set bet3een entity sets customer anaccount may ha(e the attribute access-date

Page 7: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 7/52

CMSC 461- Dr. Kalpakis 

7

 $e%ree o' a Relationship "et 

Degreethe number o" entity sets that parti#ipate in arelationship set&

Relationship sets that in(ol(e t3o entity sets are binary +or

egree t3o&

5enerally, most relationship sets in a atabase system are

 binary, e(en though there are #ases 3here higher egree

relationship sets o##ur 

Page 8: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 8/52

CMSC 461- Dr. Kalpakis 

8

 appin% Cardinalities

Express the number o" entities to 3hi#h another entity

#an be asso#iate (ia a relationship set&

Most use"ul in es#ribing binary relationship sets&

!or a binary relationship set the mapping #arinality

must be one o" the "ollo3ing types*

ne to one

ne to many

Many to one

Many to many

Page 9: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 9/52

CMSC 461- Dr. Kalpakis 

9

 appin% Cardinalities

One to one One to many

Page 10: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 10/52

CMSC 461- Dr. Kalpakis 

10

 appin% Cardinalities

Many to one Many to many

Page 11: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 11/52

CMSC 461- Dr. Kalpakis 

11

 E-R $ia%rams

Rectangles represent entity sets

Diamonds represent relationship sets&

Lines lin. attributes to entity sets an entity sets to relationship

sets&

Ellipses represent attributesDouble ellipses represent multi(alue attributes

Dashed ellipses enote eri(e attributes&

Underline ini#ates primary .ey attributes +3ill stuy later

7e express #arinality #onstraints by ra3ing either a ire#te

line +→, signi"ying 8one,9 or an unire#te line +:, signi"ying

8many,9 bet3een the relationship set an the entity set&

Page 12: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 12/52

CMSC 461- Dr. Kalpakis 

12

 E-R $ia%ram E(ample

Page 13: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 13/52

CMSC 461- Dr. Kalpakis 

13

 E-R $ia%ram E(ample

Page 14: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 14/52

CMSC 461- Dr. Kalpakis 

14

 E-R $ia%ram E(ample

Page 15: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 15/52

CMSC 461- Dr. Kalpakis 

15

 Roles

Entity sets o" a relationship nee not be istin#t

;se roles to spe#i"y the purpose o" ea#h entity in the relationship

Roles are ini#ate in E-R iagrams by labeling the lines that #onne#t

iamons to re#tangles&

Role labels are optional, an are use to #lari"y semanti#s o" the relationship

Page 16: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 16/52

CMSC 461- Dr. Kalpakis 

16

 )articipation o' an Entity "et in a Relationship "et 

$otal parti#ipation +ini#ate by ouble line

e(ery entity in the entity set parti#ipates in at least one relationship in the

relationship set

<artial parti#ipation* some entities may not parti#ipate in any

relationship in the relationship set

Page 17: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 17/52

CMSC 461- Dr. Kalpakis 

17

 *eys

% super key o" an entity set is a set o" one or more attributes

3hose (alues uni=uely etermine ea#h entity&

% candidate key o" an entity set is a minimal super .ey

Customer-id  is #aniate .ey o" customer 

account-number  is #aniate .ey o" account 

%lthough se(eral #aniate .eys may exist, one o" the #aniate

.eys is sele#te to be the primary key

Page 18: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 18/52

CMSC 461- Dr. Kalpakis 

18

 *eys 'or Relationship "ets

$he #ombination o" primary .eys o" the parti#ipating entity sets

"orms a super .ey o" a relationship set&

Must #onsier the mapping #arinality o" the relationship set

3hen e#iing 3hat are the #aniate .eys

 >ee to #onsier semanti#s o" relationship set in sele#ting the primary key in #ase o" more than one #aniate .ey

Page 19: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 19/52

CMSC 461- Dr. Kalpakis 

19

Cardinality Constraints on +ernary Relationships

7e allo3 at most one arro3 out o" a ternary +or greater egree

relationship to ini#ate a #arinality #onstraint

More than one arro3s lea to ambiguities in the semanti#s o"

the #arinality #onstraint, an thus are not permitte

Page 20: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 20/52

CMSC 461- Dr. Kalpakis 

20

 ,inary &s. non-,inary Relationships

Some relationships that appear to be non-binary may be better

represente using binary relationships

E&g& % ternary relationship parents, relating a #hil to his?her "ather an

mother, is best repla#e by t3o binary relationships,  'ather  an mother 

;sing t3o binary relationships allo3s partial in"ormation +e&g& only mother

 being .no3

@ut there are some relationships that are naturally non-binary

E&g& works-on

Page 21: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 21/52

CMSC 461- Dr. Kalpakis 

21

Con&ertin% on-,inary Relationships to ,inary Relationships

In general, any non-binary relationship #an be represente using

 binary relationships by #reating an arti"i#ial entity set&

Page 22: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 22/52

CMSC 461- Dr. Kalpakis 

22

Con&ertin% on-,inary Relationships

%lso nee to translate #onstraints

$ranslating all #onstraints may not be possible

$here may be instan#es in the translate s#hema that

#annot #orrespon to any instan#e o" R

 E(ercise: add constraints to the relationships R #  R , and RC to ensure that a

ne3ly #reate entity #orrespons to exa#tly one entity in ea#h o" entity sets

 # , an C 

7e #an a(oi #reating an ienti"ying attribute by ma.ing E a 3ea. entity

set +es#ribe shortly ienti"ie by the three relationship sets

Page 23: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 23/52

CMSC 461- Dr. Kalpakis 

23

 E-R $esi%n ssues

;se o" entity sets (s& attributes

Choi#e mainly epens on the stru#ture o" the enterprise being moele, an

on the semanti#s asso#iate 3ith the attribute in =uestion&

;se o" entity sets (s& relationship sets

<ossible guieline is to esignate a relationship set to es#ribe an a#tion that

o##urs bet3een entities

@inary (ersus n-ary relationship sets

%lthough it is possible to repla#e any nonbinary +n-ary, "or n A relationship

set by a number o" istin#t binary relationship sets, a n-ary relationship set

sho3s more #learly that se(eral entities parti#ipate in a single relationship&

<la#ement o" relationship attributes

Page 24: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 24/52

CMSC 461- Dr. Kalpakis 

24

0eak Entity "ets

%n entity set that oes not ha(e a primary .ey is re"erre to as a weak entity

 set &

$he existen#e o" a 3ea. entity set epens on the existen#e o" a identi'yin%

entity set 

 it must relate to the ienti"ying entity set (ia a total, one-to-many relationship

set "rom the ienti"ying to the 3ea. entity setIenti"ying relationship epi#te using a ouble iamon

$he discriminator  or partial key2 o" a 3ea. entity set is the set o" attributes

that istinguishes among all the entities o" a 3ea. entity set&

$he primary .ey o" a 3ea. entity set is "orme by the primary .ey o" thestrong entity set on 3hi#h the 3ea. entity set is existen#e epenent, plus

the 3ea. entity setBs is#riminator&

Page 25: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 25/52

CMSC 461- Dr. Kalpakis 

25

0eak Entity "ets

7e epi#t a 3ea. entity set by ouble re#tangles&

7e unerline the is#riminator o" a 3ea. entity set 3ith a

ashe line&

7hat happens i" payment ha attribute loan-number

Page 26: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 26/52

CMSC 461- Dr. Kalpakis 

26

"peciali3ation

$op-o3n esign pro#ess 3e esignate subgroupings 3ithin an entity

set that are istin#ti(e "rom other entities in the set&

$hese subgroupings be#ome lo3er-le(el entity sets that ha(e attributes or

 parti#ipate in relationships that o not apply to the higher-le(el entity set&

Depi#te by a trian%le #omponent labele IS% 

$he IS% relationship is also re"erre to as superclass – subclass

relationship

Attribute inheritance

a lo3er-le(el entity set inherits all the attributes an relationship

 parti#ipation o" the higher-le(el entity set to 3hi#h it is lin.e&

Can ha(e multiple spe#ialiations o" an entity set base on i""erent

"eatures&

Page 27: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 27/52

CMSC 461- Dr. Kalpakis 

27

"peciali3ation E(ample

Page 28: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 28/52

CMSC 461- Dr. Kalpakis 

28

enerali3ation

% bottom-up esign pro#ess

#ombine a number o" entity sets that share the same "eatures into a

higher-le(el entity set&

Spe#ialiation an generaliation are simple in(ersions o" ea#h

other they are represente in an E-R iagram in the same 3ay&

$he terms spe#ialiation an generaliation are use

inter#hangeably&

Page 29: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 29/52

CMSC 461- Dr. Kalpakis 

29

 "# $esi%n Constraints

Constraint on 3hi#h entities #an be members o" a gi(en lo3er-

le(el entity set&

#onition-e"ine

user-e"ine

Constraint on 3hether or not entities may belong to more thanone lo3er-le(el entity set 3ithin a single generaliation&

Dis'oint

an entity #an belong to only one lo3er-le(el entity set

note in E-R iagram by 3riting dis5oint  next to the IS% triangle

(erlapping

an entity #an belong to more than one lo3er-le(el entity set

Page 30: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 30/52

CMSC 461- Dr. Kalpakis 

30

 "# $esi%n Constraints

Completeness #onstraint

spe#i"ies 3hether or not an entity in the higher-le(el entity set must

 belong to at least one o" the lo3er-le(el entity sets 3ithin a

generaliation&

total * an entity must belong to one o" the lo3er-le(el entity sets

partial* an entity nee not belong to any o" the lo3er-le(el entity sets

Page 31: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 31/52

CMSC 461- Dr. Kalpakis 

31

 #%%re%ation

Suppose 3e 3ant to re#or managers "or tas.s per"orme by an employee at

a bran#h

Page 32: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 32/52

CMSC 461- Dr. Kalpakis 

32

 #%%re%ation

Relationship sets works-on an mana%es represent o(erlapping in"ormation

E(ery mana%es relationship #orrespons to a works-on relationship

Fo3e(er, some works-on relationships may not #orrespon to any mana%es 

relationships

So 3e #anBt is#ar the works-on relationship

Eliminate this reunan#y (ia a%%re%ation$reat relationship as an abstra#t entity

%llo3s relationships bet3een relationships

%bstra#tion o" relationship into ne3 entity

7ithout introu#ing reunan#y, the "ollo3ing iagram represents*%n employee 3or.s on a parti#ular 'ob at a parti#ular bran#h

%n employee, bran#h, 'ob #ombination may ha(e an asso#iate manager 

Page 33: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 33/52

CMSC 461- Dr. Kalpakis 

33

 E-R $ia%ram 0ith #%%re%ation

Page 34: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 34/52

CMSC 461- Dr. Kalpakis 

34

 $esi%n )hases

Spe#i"i#ation o" user re=uirements

5ather userBs ata re=uirements

5ather userBs "un#tional re=uirements

Con#eptual esign

$ranslate the userBs ata re=uirement into a #on#eptual s#hema "or the #hosen

ata moel to #reate a etaile o(er(ie3 o" the userBs enterpriseRe(ie3 "or in#onsisten#ies an #o(erage

Gogi#al esign

Map the #on#eptual s#hema onto the ata moel o" the #hosen atabase system

<hysi#al esignSpe#i"y the physi#al #hara#teristi#s o" the implementation o" the logi#al s#hema

Page 35: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 35/52

CMSC 461- Dr. Kalpakis 

35

 E-R $esi%n $ecisions

$he use o" an attribute or entity set to represent an ob'e#t&

7hether a real-3orl #on#ept is best expresse by an entity set

or a relationship set&

$he use o" a ternary relationship (ersus a pair o" binary

relationships&

$he use o" a strong or 3ea. entity set&

$he use o" IS% ) #ontributes to moularity in the esign&

$he use o" aggregation ) #an treat the aggregate entity set as asingle unit 3ithout #on#ern "or the etails o" its internal

stru#ture&

Page 36: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 36/52

CMSC 461- Dr. Kalpakis 

36

 ,ankin% Enterprise - $ata Reuirements

@an.

is organie into bran#hes

ea#h bran#h is lo#ate in a parti#ular #ity an has a uni=ue name

Customers

are ienti"ie by an i

Fa(e a##ounts an?or loans

May be asso#iate 3ith a parti#ular ban. employee as loan o""i#er?personal

 ban.er 

@an. stores #ustomerBs name an aress

EmployeesIenti"ie by an i

Store his?her name, telephone numbers, names o" epenents, start ate,

manager, an length o" employment

Page 37: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 37/52

CMSC 461- Dr. Kalpakis 

37

 ,ankin% Enterprise - $ata Reuirements

Accounts

%re ienti"ie by an i

Can be #he#.ing or sa(ings

May be hel by multiple #ustomers

@an. maintains a##ountBs balan#e an ate o" last a##ess

Ea#h sa(ings a##ount has an interest rate

@an. maintains the o(erra"t amount "or ea#h #he#.ingLoans

%re ienti"ie by an i an originate at a parti#ular bran#h

May be hel by multiple #ustomers

Maintain loan amount an payments

!or ea#h payment "or a loan, the ban. maintains the ate an amount o" payment

Ea#h loan payment is asso#iate 3ith a parti#ular loan an is ienti"ie by a

 payment number, uni=ue among the payments "or that loan

Page 38: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 38/52

CMSC 461- Dr. Kalpakis 

38

 E-R $ia%ram 'or a ,ankin% Enterprise

Page 39: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 39/52

CMSC 461- Dr. Kalpakis 

39

"ummary o' E-R "ymbols

Page 40: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 40/52

CMSC 461- Dr. Kalpakis 

40

"ummary o' E-R "ymbols

Page 41: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 41/52

CMSC 461- Dr. Kalpakis 

41

 #lternati&e E-R otations

Page 42: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 42/52

CMSC 461- Dr. Kalpakis 

42

 Reduction o' an E-R "chema to +ables

<rimary .eys allo3 entity sets an relationship sets to be

expresse uni"ormly as tables 3hi#h represent the #ontents o"the atabase&

% atabase 3hi#h #on"orms to an E-R iagram #an be represente by a

#olle#tion o" tables&

!or ea#h entity set an relationship set there is a uni=ue table

3hi#h is assigne the name o" the #orresponing entity set or

relationship set&

Ea#h table has a number o" #olumns +generally #orresponing to

attributes, 3hi#h ha(e uni=ue names&

Con(erting an E-R iagram to a table "ormat is the basis "or

eri(ing a relational atabase esign "rom an E-R iagram&

Page 43: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 43/52

CMSC 461- Dr. Kalpakis 

43

 Representin% Entity "ets as +ables

% strong entity set reu#es to a table 3ith the same attributes

Page 44: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 44/52

CMSC 461- Dr. Kalpakis 

44

Composite #ttributes

Composite attributes are "lattene out by #reating a separate

attribute "or ea#h #omponent attribute

E&g& gi(en entity set customer 3ith #omposite attribute name 3ith

#omponent attributes 'irst-name an last-name the table #orresponing

to the entity set has t3o attributes

  name.'irst-name  an name.last-name

Page 45: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 45/52

CMSC 461- Dr. Kalpakis 

45

 ulti-&alued #ttributes

% multi-(alue attribute M o" an entity E is represente by a

separate table EM

$able EM has attributes #orresponing to the primary .ey o" E an an

attribute #orresponing to multi-(alue attribute M

e&g& Multi-(alue attribute dependent-names o" employee is represente by

a table

  employee-dependent-names+employee-id dname 

Ea#h (alue o" the multi-(alue attribute maps to a separate ro3 o" the

table EM

E&g&, an employee entity 3ith primary .ey Hohn anepenents Mar. an Mary maps to t3o ro3s*

+Hohn, Mar. an +Hohn, Mary

Page 46: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 46/52

CMSC 461- Dr. Kalpakis 

46

 Representin% 0eak Entity "ets

A weak entity set becomes a table that includes columns for the

primary key of the identifying strong entity set

Page 47: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 47/52

CMSC 461- Dr. Kalpakis 

47

 Representin% Relationship "ets as +ables

% many-to-many relationship set is represente as a table 3ith

#olumns "or the primary .eys o" the t3o parti#ipating entity

sets, an any es#ripti(e attributes o" the relationship set&

E&g&* table "or relationship set borrower 

Page 48: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 48/52

CMSC 461- Dr. Kalpakis 

48

 Redundancy o' +ables

Many-to-one an one-to-many relationship sets that are total on the many-

sie #an be represente by aing an extra attribute to the many sie,#ontaining the primary .ey o" the one sie

!or one-to-one relationship sets, either sie #an be #hosen to a#t as the8many9 sie

I" parti#ipation is partial  on the many sie, repla#ing a table by an extraattribute in the relation #orresponing to the 8many9 sie #oul result in null(alues

$he table #orresponing to a relationship set lin.ing a 3ea. entity set to itsienti"ying strong entity set is reunant&

" l bl

Page 49: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 49/52

CMSC 461- Dr. Kalpakis 

49

 Representin% "peciali3ation as +ables

Method 1 

!orm a table "or the higher le(el entity

!orm a table "or ea#h lo3er le(el entity set, that in#lues

 primary .ey o" higher le(el entity set an lo#al attributes

  table   table attributes

 person name street city

customer name credit-ratin% 

employee name salary

Dra3ba#.* getting in"ormation about, e&g&, employee 

re=uires a##essing t3o tables

Page 50: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 50/52

CMSC 461- Dr. Kalpakis 

50

 Representin% "peciali3ation as +ables

Method 2 

!orm a table "or ea#h entity set 3ith all lo#al an inherite attributes

table table attributes

 person name street city

customer name street city credit-ratin% 

employee name street city salary

I" spe#ialiation is total, table "or generalie entity + person not

re=uire to store in"ormation

Can be e"ine as a 8(ie39 relation #ontaining union o" spe#ialiation tables@ut expli#it table may still be neee "or "oreign .ey #onstraints

Dra3ba#.* street an #ity may be store reunantly "or persons 3ho

are both #ustomers an employees

Page 51: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 51/52

CMSC 461- Dr. Kalpakis 

51

 Relations Correspondin% to #%%re%ation

$o represent relationships 3ith aggregate entities, #reate a

table #ontaining

$he primary .ey o" the aggregate entity

the primary .ey o" the asso#iate entity

%ny es#ripti(e attributes o" the relationship

Example

mana%es+employee-id branch-name 5ob-title mana%er-name

$able works-on is reunant if null (alues "or attribute mana%er -name intable mana%es are allo3e

Page 52: Entity Relations Model

8/10/2019 Entity Relations Model

http://slidepdf.com/reader/full/entity-relations-model 52/52

 E-R $ia%ram 7 ,ookstore E(ample