er modeling chittaranjan pradhan database management · er modeling... chittaranjan pradhan keys...

13
ER Modeling... Chittaranjan Pradhan Keys Keys for Relationship sets Relationship Types Participation Constraints l..h Representation Alternate Mapping Cardinality Representation Strong Entity sets and Weak Entity sets 6.1 Database Management System 6 ER Modeling... Chittaranjan Pradhan School of Computer Engineering, KIIT University

Upload: others

Post on 04-Apr-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ER Modeling Chittaranjan Pradhan Database Management · ER Modeling... Chittaranjan Pradhan Keys Keys for Relationship sets Relationship Types Participation Constraints l..h Representation

ER Modeling...

Chittaranjan Pradhan

KeysKeys for Relationship sets

Relationship Types

ParticipationConstraintsl..h Representation

Alternate MappingCardinality Representation

Strong Entity sets andWeak Entity sets

6.1

Database ManagementSystem 6ER Modeling...

Chittaranjan PradhanSchool of Computer Engineering,

KIIT University

Page 2: ER Modeling Chittaranjan Pradhan Database Management · ER Modeling... Chittaranjan Pradhan Keys Keys for Relationship sets Relationship Types Participation Constraints l..h Representation

ER Modeling...

Chittaranjan Pradhan

KeysKeys for Relationship sets

Relationship Types

ParticipationConstraintsl..h Representation

Alternate MappingCardinality Representation

Strong Entity sets andWeak Entity sets

6.2

Keys

Keys

A key allows us to identify a set of attributes that suffice todistinguish entities from each other

• A key is a property of the entity set, rather than of theindividual entities

• A super key is a set of one or more attributes that allow usto identify uniquely an entity in an entity set

• The minimal super keys are called candidate keys• Primary key is a candidate key that is chosen by the

database designer as the principal means of identifyingentities within an entity set. The primary key can berepresented by underlying the attribute name. The primarykey should be chosen such that its attributes are never orvery rarely changed

• The remaining candidate keys except the primary key arecalled as alternate keys

Page 3: ER Modeling Chittaranjan Pradhan Database Management · ER Modeling... Chittaranjan Pradhan Keys Keys for Relationship sets Relationship Types Participation Constraints l..h Representation

ER Modeling...

Chittaranjan Pradhan

KeysKeys for Relationship sets

Relationship Types

ParticipationConstraintsl..h Representation

Alternate MappingCardinality Representation

Strong Entity sets andWeak Entity sets

6.3

Keys...

• If none of the columns is a candidate for the primary key ina table, sometimes database designers use an extracolumn as a primary key instead of using a composite key.Such key is known as the surrogate key

• Foreign key is the set of attributes which is used forreferring to another entity set having the primary key. InER diagram, foreign key can not be represented

Page 4: ER Modeling Chittaranjan Pradhan Database Management · ER Modeling... Chittaranjan Pradhan Keys Keys for Relationship sets Relationship Types Participation Constraints l..h Representation

ER Modeling...

Chittaranjan Pradhan

KeysKeys for Relationship sets

Relationship Types

ParticipationConstraintsl..h Representation

Alternate MappingCardinality Representation

Strong Entity sets andWeak Entity sets

6.4

Keys for Relationship sets

Keys for Relationship sets

Let R be a relationship set involving entity sets E1, E2, ... En.Let PK(Ei ) denotes the set of attributes that forms the primarykey for entity set Ei

• If the relationship set R has no descriptive attributesassociated with it, then the set of attributes PK(E1) UPK(E2) U ... U PK(En) describes an individual relationshipin set R

• If the relationship set R has attributes a1, a2 ... amassociated with it, then the set of attributes PK(E1) UPK(E2) U ... U PK(En) U {a1,a2,...am} describes anindividual relationship in set R

Page 5: ER Modeling Chittaranjan Pradhan Database Management · ER Modeling... Chittaranjan Pradhan Keys Keys for Relationship sets Relationship Types Participation Constraints l..h Representation

ER Modeling...

Chittaranjan Pradhan

KeysKeys for Relationship sets

Relationship Types

ParticipationConstraintsl..h Representation

Alternate MappingCardinality Representation

Strong Entity sets andWeak Entity sets

6.5

Keys for Relationship sets...

M:N relationship

The primary key of the relationship set consists of the union ofthe primary keys of the entity sets

1:M relationship

The primary key of the relationship set is the primary key of themany side entity set

Page 6: ER Modeling Chittaranjan Pradhan Database Management · ER Modeling... Chittaranjan Pradhan Keys Keys for Relationship sets Relationship Types Participation Constraints l..h Representation

ER Modeling...

Chittaranjan Pradhan

KeysKeys for Relationship sets

Relationship Types

ParticipationConstraintsl..h Representation

Alternate MappingCardinality Representation

Strong Entity sets andWeak Entity sets

6.6

Keys for Relationship sets...

1:1 relationship

The primary key of the relationship set is either the primary keyof any entity set

Page 7: ER Modeling Chittaranjan Pradhan Database Management · ER Modeling... Chittaranjan Pradhan Keys Keys for Relationship sets Relationship Types Participation Constraints l..h Representation

ER Modeling...

Chittaranjan Pradhan

KeysKeys for Relationship sets

Relationship Types

ParticipationConstraintsl..h Representation

Alternate MappingCardinality Representation

Strong Entity sets andWeak Entity sets

6.7

Relationship Types

Relationship Types

A relationship type is a meaningful association among entitytypes. The degree of a relationship type is defined as thenumber of entity sets participating in that relationship type

Binary relationship

A relationship type is said to be binary when two entity sets areinvolved

Ternary relationship

Relationship types that involve three entity sets are defined asternary relationships

Page 8: ER Modeling Chittaranjan Pradhan Database Management · ER Modeling... Chittaranjan Pradhan Keys Keys for Relationship sets Relationship Types Participation Constraints l..h Representation

ER Modeling...

Chittaranjan Pradhan

KeysKeys for Relationship sets

Relationship Types

ParticipationConstraintsl..h Representation

Alternate MappingCardinality Representation

Strong Entity sets andWeak Entity sets

6.8

Relationship Types...

Quaternary relationship

A relationship of degree four can be referred to as a quaternaryrelationship

Recursive relationship

The participation of an entity set in a relationship type can beindicated by its role name. When used in recursive relationshiptypes, role names describe the functionality of the participation

Page 9: ER Modeling Chittaranjan Pradhan Database Management · ER Modeling... Chittaranjan Pradhan Keys Keys for Relationship sets Relationship Types Participation Constraints l..h Representation

ER Modeling...

Chittaranjan Pradhan

KeysKeys for Relationship sets

Relationship Types

ParticipationConstraintsl..h Representation

Alternate MappingCardinality Representation

Strong Entity sets andWeak Entity sets

6.9

Participation Constraints

Participation Constraints

The participation constraint for an entity set in a binaryrelationship type is based on whether an entity of that entity setneeds to be related to an entity of the other entity set throughthis relationship type

• Total participation: If, in order to exist, every entity mustparticipate in the relationship, then participation of theentity set in that relationship type is total or mandatory.The total participation is represented by double lines

• Partial participation: If an entity can exist withoutparticipating in the relationship, then participation of theentity type in that relationship type is partial or optional

Page 10: ER Modeling Chittaranjan Pradhan Database Management · ER Modeling... Chittaranjan Pradhan Keys Keys for Relationship sets Relationship Types Participation Constraints l..h Representation

ER Modeling...

Chittaranjan Pradhan

KeysKeys for Relationship sets

Relationship Types

ParticipationConstraintsl..h Representation

Alternate MappingCardinality Representation

Strong Entity sets andWeak Entity sets

6.10

l..h Representation

l..h Representation

An edge between an entity set and a binary relationship setcan have an associated minimum and maximum cardinality;shown as l..h, where l is the minimum and h is the maximumcardinality

• A minimum value of 1 indicates total participation of theentity set in the relationship set

• A maximum value of 1 indicates that the entity participatesin at most one relationship, while a maximum value *indicates no limit

• 1..* indicates total participation or double line

Page 11: ER Modeling Chittaranjan Pradhan Database Management · ER Modeling... Chittaranjan Pradhan Keys Keys for Relationship sets Relationship Types Participation Constraints l..h Representation

ER Modeling...

Chittaranjan Pradhan

KeysKeys for Relationship sets

Relationship Types

ParticipationConstraintsl..h Representation

Alternate MappingCardinality Representation

Strong Entity sets andWeak Entity sets

6.11

Alternate Mapping Cardinality Representation

Alternate Mapping Cardinality Representation

Page 12: ER Modeling Chittaranjan Pradhan Database Management · ER Modeling... Chittaranjan Pradhan Keys Keys for Relationship sets Relationship Types Participation Constraints l..h Representation

ER Modeling...

Chittaranjan Pradhan

KeysKeys for Relationship sets

Relationship Types

ParticipationConstraintsl..h Representation

Alternate MappingCardinality Representation

Strong Entity sets andWeak Entity sets

6.12

Strong Entity sets and Weak Entity sets

Strong Entity sets and Weak Entity sets

An entity set where the entities have independent existence(that is, each entity is unique) is referred to as a strong or baseentity set. On the other hand, the entity set that does not haveindependent existence, that is, an entity set that does not haveits own unique identifier is known as weak entity set

• For a weak entity set to be meaningful, it must beassociated with another strong entity set calledidentifying or owner entity set

• The relationship associating the weak entity set with theidentifying entity set is called the identifying relationship

• The identifying relationship is usually many-to-one fromthe weak entity set to the identifying entity set and theparticipation of the weak entity set in the relationship istotal participation

Page 13: ER Modeling Chittaranjan Pradhan Database Management · ER Modeling... Chittaranjan Pradhan Keys Keys for Relationship sets Relationship Types Participation Constraints l..h Representation

ER Modeling...

Chittaranjan Pradhan

KeysKeys for Relationship sets

Relationship Types

ParticipationConstraintsl..h Representation

Alternate MappingCardinality Representation

Strong Entity sets andWeak Entity sets

6.13

Strong Entity sets and Weak Entity sets...

• An attribute in a weak entity set, which in conjunction witha unique identifier of the parent entity set in the identifyingrelationship type uniquely identifies weak entities, is calledthe partial key of the weak entity set and is denoted by adotted underline. The partial key of a weak entity set issometimes referred to as a discriminator

• The primary key of a weak entity set is formed by theprimary key of the identifying entity set, plus the weakentity set’s discriminator