Download presentation
Presentation is loading. Please wait.
Published byMarvin Harris Modified over 9 years ago
1
Bordoloi CMIS 450 Database Design Dr. Bijoy Bordoloi Entity Relationship (E-R) Model
2
Bordoloi E-R Modeling and Logical Database Design The Entity Relationship Model The Relational Model Transforming E-R Diagrams into Relations Normalization
3
Bordoloi E-R Model Constructs EntitiesEntities RelationshipsRelationships CardinalityCardinality AttributesAttributes Sub-entities (EER)Sub-entities (EER) ExamplesExamples
4
Bordoloi Definition of Entity An entity type is a set of entity instances sharing the same common properties (‘attributes’), characterized by:An entity type is a set of entity instances sharing the same common properties (‘attributes’), characterized by: –Name - a noun, e.g., EMPLOYEE –Description - defines which instances belong to the entity type E –Identifier - a property (or a joint set of properties) which uniquely identify entity instances An entity instance is a single identifiable real- world thing, e.g., Jack SprattAn entity instance is a single identifiable real- world thing, e.g., Jack Spratt
5
Bordoloi Entity Types DEPARTMENT EMPLOYEE PROJECT SUPPLIER
6
Bordoloi Attributes Any property of an owner entityAny property of an owner entity Attribute typeAttribute type –A set of attribute instances expressing the same property of an entity type, e.g., Gender Attribute instanceAttribute instance –A particular property of an individual entity instance, e.g., Male
7
Bordoloi Attributes EMPLOYEE EMP-ID SS-NUM EMP- NAME PHONE
8
Bordoloi An attribute (or a joint set of attributes) which uniquely identify the entity instances of an entity An attribute (or a joint set of attributes) which uniquely identify the entity instances of an entity An identifier should be: An identifier should be: - Unique and known (must not be ‘NULL’) - Unique and known (must not be ‘NULL’) - Short (preferably) - Short (preferably) - Stable (preferably) - Stable (preferably) Identifier
9
Bordoloi What would you choose as the Identifier of the entity type EMPLOYEE? EMPLOYEE EMP-ID SS-NUM EMP- NAME PHONE
10
Bordoloi What Should an Entity Be? SHOULD BE:SHOULD BE: –An object that will have many instances in the database –An object that will be composed of multiple attributes –An object that we are trying to model –Must have an identifier SHOULD NOT BE:SHOULD NOT BE: –A user of the database system –An output of the database system (e.g. a report)
11
Bordoloi Inappropriate entities System user System output Appropriate entities Figure 3-4
12
Bordoloi Entity B is existence-dependent on entity A whenEntity B is existence-dependent on entity A when –Some instance of A must exist before B can exist –If A ceases to exist, B must also cease to exist An independent entity is not existence-dependent on any other entityAn independent entity is not existence-dependent on any other entity Independent Entity – Strong EntityIndependent Entity – Strong Entity Dependent Entity – Weak EntityDependent Entity – Weak Entity Diagramming conventionDiagramming convention Dependent and Independent Entities
13
Bordoloi Typically the identifier of a weak entity is a composite identifier which includes the identifier of the entity which the weak entity is existence- dependent uponTypically the identifier of a weak entity is a composite identifier which includes the identifier of the entity which the weak entity is existence- dependent upon Diagramming conventionDiagramming convention Dependent and Independent Entities
14
Bordoloi Dependent and Independent Entities ExamplesExamples OFFERINGCOURSE TASKPROJECT DEPENDS ON
15
Bordoloi Relationships An association between two or more entities, of significance to the enterpriseAn association between two or more entities, of significance to the enterprise Relationships are named with a verb an depicted as lines between entitiesRelationships are named with a verb an depicted as lines between entities SUPPLIER PART EMPLOYEE COMPANY SHIP WORK FOR
16
Bordoloi Degree The degree of a relationship is the number of associated entitiesThe degree of a relationship is the number of associated entities Relationships are usually of degree 2 (binary) - but sometimes can be unary or of higher degree (N-ary)Relationships are usually of degree 2 (binary) - but sometimes can be unary or of higher degree (N-ary)
17
Bordoloi Binary Relationships The relationship involves at the most only two entitiesThe relationship involves at the most only two entities SUPPLIERPART EMPLOYEECOMPANY SHIP WORK FOR
18
Bordoloi Unary Relationships Relationships may associate an entity with itself, i.e., when an instance of an entity is related to some other instance(s) of the same entity.Relationships may associate an entity with itself, i.e., when an instance of an entity is related to some other instance(s) of the same entity. EMPLOYEE Married_to
19
Bordoloi Ternary Relationship The relationship involves three entitiesThe relationship involves three entities COMPANY PRODUCT AGENT SELL
20
Bordoloi Several relationships may exist between the same entitiesSeveral relationships may exist between the same entities The name and description distinguishes different relationships between the same entitiesThe name and description distinguishes different relationships between the same entities Relationships EMPLOYEEDEPARTMENT MANAGE FORMERLY WORKED IN WORK IN
21
Bordoloi Cardinality Constraints Cardinality Constraints A binary relationship (E 1,E 2 ) has two directions, left and rightA binary relationship (E 1,E 2 ) has two directions, left and right Each direction has cardinality constraints, described as maximum and mimimu.Each direction has cardinality constraints, described as maximum and mimimu.
22
Bordoloi Cardinality Constraints Cardinality Constraints - the number of instances of one entity that can or must be associated with each instance of another entity.Cardinality Constraints - the number of instances of one entity that can or must be associated with each instance of another entity. Maximum Cardinality (can be)Maximum Cardinality (can be) –The maximum number Minimum Cardinality (must be) –If zero, then optional –If one or more, then mandatory
23
Bordoloi Maximum Cardinality Maximum Cardinality The maximum cardinality of a direction E 1 to E 2 indicates how many e 2 ’s can match a given e1 (at most)The maximum cardinality of a direction E 1 to E 2 indicates how many e 2 ’s can match a given e1 (at most) Cardinality is denoted as MaxLeft - MaxRightCardinality is denoted as MaxLeft - MaxRight –1-1 –1-N –N-1 –M-N
24
Bordoloi Cardinality Cardinality EMPLOYEEDEPARTMENT WORK-IN ONE DEPARTMENT EACH EMPLOYEE MANY EMPLOYEES EACH DEPARTMENT MANYONE
25
Bordoloi Examples of Cardinality Examples of Cardinality EMPLOYEEDEPARTMENT N1 WORKS-IN E1E1 E2E2 E3E3 E4E4 D1D1 D2D2 D3D3 D4D4
26
Bordoloi Examples of Cardinality Examples of Cardinality 11 MN E1E1 E2E2 E3E3 E4E4 D1D1 D2D2 D3D3 D4D4 E1E1 E2E2 E3E3 E4E4 D1D1 D2D2 D3D3 D4D4 MANAGE FORMERLY WORKED-IN
27
Bordoloi Minimum Cardinality Minimum Cardinality Minimum cardinality is specified as zero to oneMinimum cardinality is specified as zero to one EMPLOYEEDEPARTMENT WORK IN ONE DEPARTMENT EACH EMPLOYEE ZERO EMPLOYEES EACH DEPARTMENT ZEROONE
28
Bordoloi Minimum Cardinality Minimum Cardinality For the purpose of our course, we will use:For the purpose of our course, we will use: Instructor teaches One to many (maximum cardinality) Mandatory Optional (minimum cardinality)
29
Bordoloi Summary of Cardinality Minimum and maximum cardinality is specified for each direction of a relationshipMinimum and maximum cardinality is specified for each direction of a relationship Maximum cardinality is either one or many for each directionMaximum cardinality is either one or many for each direction Minimum cardinality is either zero or one for each directionMinimum cardinality is either zero or one for each direction
30
Bordoloi Terminology Terminology A single-valued relationship (from entity A to entity B) has maximum cardinality of one (from A to B)A single-valued relationship (from entity A to entity B) has maximum cardinality of one (from A to B) A multi-valued relationship has maximum cardinality of manyA multi-valued relationship has maximum cardinality of many When we speak of single-valued and multi- valued relationships, a direction is implicitWhen we speak of single-valued and multi- valued relationships, a direction is implicit
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.