entity relationship diagrams
DESCRIPTION
Entity Relationship Diagrams. Mr.Prasad Sawant MIT PUNE. Universe of Discourse. REQUIREMENTS COLLECTION AND ANALYSIS. FUNCTIONAL ANALYSIS. APPLICATION PROGRAM DESIGN. Software Analysis & Design. Description of requirements of users data modelling, process modelling - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/1.jpg)
Entity Relationship Diagrams
Mr.Prasad Sawant MIT PUNE
![Page 2: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/2.jpg)
Software Analysis & Design
Universeof Discourse
REQUIREMENTSCOLLECTION
AND ANALYSIS
FUNCTIONALANALYSIS
APPLICATIONPROGRAM
DESIGN
Description of requirements of users data modelling, process modelling
Data modelling is expressed using a high level model such as ENTITY-RELATIONSHIP (ER)
The ER Model represented pictorially (ER diagrams)
ER Model contains detailed descriptions of:
What are the entities and relationships in the enterprise?
What information about these entities and relationships should we store in the database?
What are the integrity constraints or business rules that hold?
![Page 3: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/3.jpg)
Data modelling vs Process modelling Process modelling (i.e. DFD) shows
data stores, how, where, when data are used or changed in an System
Data modelling (i.e ER) shows the definition, structure, & relationship within the data
![Page 4: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/4.jpg)
Conceptual Data Modeling and the E-R Diagram Goal
Capture as much of the meaning of the data as possible
A better design that is scalable and easier to maintain
![Page 5: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/5.jpg)
Introduction to Entity-Relationship (E-R) Modeling Notation uses three main constructs
Data entities Attributes Relationships
Entity-Relationship (E-R) Diagram A detailed, logical representation of the
entities, associations and data elements for an organization or business
![Page 6: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/6.jpg)
Entity-Relationship (E-R) ModelingKey TermsEntity
A person, place, object, event or concept in the user environment about which the organization wishes to maintain data
Represented by a rectangle in E-R diagramsEntity Type
A collection of entities that share common properties or characteristics
Attribute A named property or characteristic of an entity
that is of interest to an organization
![Page 7: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/7.jpg)
Entity-Relationship (E-R) ModelingKey Terms
Candidate keys and identifiersEach entity type must have an attribute
or set of attributes that distinguishes one instance from other instances of the same type
Candidate keyAttribute (or combination of attributes) that
uniquely identifies each instance of an entity type
![Page 8: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/8.jpg)
Entity-Relationship (E-R) ModelingKey Terms
Identifier A candidate key that has been selected as the
unique identifying characteristic for an entity type
Selection rules for an identifier1. Choose a candidate key that will not change its
value2. Choose a candidate key that will never be null3. Avoid using intelligent keys4. Consider substituting single value surrogate
keys for large composite keys
![Page 9: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/9.jpg)
Notation Guide
ENTITY TYPE
WEAK ENTITY TYPE
RELATIONSHIP TYPE
IDENTIFYING RELATIONSHIP TYPE
![Page 10: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/10.jpg)
… Notation Guide
ATTRIBUTE
KEY ATTRIBUTE
MULTIVALUED ATTRIBUTE
DERIVED ATTRIBUTE
COMPOSITE ATTRIBUTE
__________
. . .
![Page 11: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/11.jpg)
ER Diagram Basics
RelationshipRelationship
AttributesAttributes
EntityEntity
Product
Keeps
Store
descrip
qty
price
pname
manager
Locations
sname
![Page 12: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/12.jpg)
Entity Sets
A collection of similar entities (e.g. all employees) All entities in an entity set have the same set of
attributes Each attribute has a domain Can map entity set to a relation easily
SSN NAME SAL321-23-3241 Kim 23,000645-56-7895 Jones 45,000
EMPLOYEES
![Page 13: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/13.jpg)
Entity Type
Defines set of entities that have the same attributes (e.g. EMPLOYEE)
Each Entity Type is described by its NAME and attributes
The Entity Type describes the “Schema” or “Intension” for a set of entities
Collection of all entities of a particular entity type at a given point in time is called the “Entity Set” or “Extension” of an Entity Type
Entity Type and Entity Set are customarily referred to by the same name
EMPLOYEE
salSSN
name
Notation
![Page 14: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/14.jpg)
Attributes
Key AttributesAttribute Types
NotationNotation
![Page 15: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/15.jpg)
Key Attributes: Identifier
Key (or uniqueness) constraints are applied to entity types
Key attribute’s values are distinct for each individual entity in the entity set
A key attribute has its name underlined inside the oval
Key must hold for every possible extension of the entity type
Multiple keys are possible
EMPLOYEE
SSN
![Page 16: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/16.jpg)
Null Valued Attributes
A particular entity may not have an applicable value for an attribute
– Home-Phone: Not known if it exists– Height: Not known at present time
Type of Null Values– Not Applicable– Unknown– Missing
![Page 17: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/17.jpg)
Composite Vs. Simple Attributes
Composite attributes can be divided into smaller parts which represent simple attributes with independent meaning
Simple Attribute: Aircraft-Type Complex Attribute: Aircraft-Location
which is comprised of :Aircraft-LatitudeAircraft-LongitudeAircraft-Altitude
Notation
… … There is no formal concept of “compositeThere is no formal concept of “compositeattribute” in the relational modelattribute” in the relational model
![Page 18: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/18.jpg)
Simple attributes can either be single-valuedor multi-valued Single-valued: Gender = F Notation
Multivalued: Degree = {BSc, MInfTech} Notation
… An “attribute” in the relational model is always single valued - Values are atomic!
Single Vs. Multivalued Attributes
![Page 19: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/19.jpg)
Derived Vs. Stored AttributesSome attribute values can be derived fromrelated attribute values: Age ® Date - B-day Y-Sal ® 12 * M-Sal
EMPLOYEE
M-salB-days Y-sal
Age
NotationNotation
![Page 20: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/20.jpg)
Derived Vs. Stored Attributes
Some attribute values can be derived from attributed values of related entities
total-value ® sum (qty * price)
Order
Item price
qty
Total-Value
![Page 21: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/21.jpg)
Representing Attributes Parenthesis ( ) for composite attributes Brackets { } for multi-valued attributes
Assume a person can have more than one residence and each residence can have multiple telephones
{AddressPhone ({ Phone ( AreaCode,PhoneNum ) }, Address (StreetAddresss (Number, Street, AptNo),
City,State,PostalCode) ) }
![Page 22: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/22.jpg)
Entity-Relationship (E-R) ModelingKey Terms
Relationship An association between the instances of
one or more entity types that is of interest to the organization
Association indicates that an event has occurred or that there is a natural link between entity types
Relationships are always labeled with verb phrases
![Page 23: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/23.jpg)
Cardinality The number of instances of entity B that
can be associated with each instance of entity A
Minimum Cardinality The minimum number of instances of entity B
that may be associated with each instance of entity A
This is also called “modality”. Maximum Cardinality
The maximum number of instances of entity B that may be associated with each instance of entity A
![Page 24: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/24.jpg)
Naming and Defining Relationships Relationship name is a verb phrase Avoid vague names Guidelines for defining relationships
Definition explains what action is being taken and why it is important
Give examples to clarify the action Optional participation should be explained Explain reasons for any explicit maximum
cardinality
![Page 25: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/25.jpg)
Naming and Defining RelationshipsGuidelines for defining relationships
Explain any restrictions on participation in the relationship
Explain extent of the history that is kept in the relationship
Explain whether an entity instance involved in a relationship instance can transfer participation to another relationship instance
10.25
![Page 26: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/26.jpg)
Relationships
Relationship Types and SetsRelationship DegreeEntity Roles and Recursive RelationshipsRelationship ConstraintsAttributes of Relationship Types
![Page 27: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/27.jpg)
Relationship Types and SetsA Relationship is an association among two or
more entities (e.g John works in Pharmacy department)
A Relationship Type defines the relationship, and a Relationship Set represents a set of relationship instances
A Relationship Type thus defines the structure of the Relationship Set Relationship Type and corresponding Set are customarily referred to by the same name
![Page 28: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/28.jpg)
Relationship Degree
The degree of a relationship type is the number of participating entity types– 2 entities: Binary Relationship 3 entities: Ternary Relationship n entities: N-ary Relationship– Same entity type could participate in multiple relationship types
PartPart
SupplierSupplier SupplySupply ProjectProject
EmployeesEmployees
DepartmentsDepartments
Works_InWorks_In
Assigned_toAssigned_to
TernaryTernary
MultipleMultiple
BinaryBinary
![Page 29: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/29.jpg)
Entity Roles
Each entity type thatparticipates in a relationshiptype plays a particular rolein the relationship type
The role name signifies therole that a participatingentity from the entity typeplays in each relationshipinstance, i.e. it explains whatthe relationship means
Employees
Works_InWorks_In
Departments
employeremployer
workerworker
RoleRoleNamesNames
![Page 30: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/30.jpg)
Recursive Relationships Same entity type can participate more than once in
the same relationship type under different “roles”
Such relationships are called“Recursive Relationships”
EmployeesEmployees
SupervisorSupervisor SubordinateSubordinateRecursiveRecursiveRelationshipRelationship
SupervisionSupervision
![Page 31: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/31.jpg)
Relationship Constraints
What are Relationship Constraints ?Constraints on relationships are determined
by the UoD, which these relationships are describing
Constraints on the relationship type limit the possible combination of entities that may participate in the corresponding relationship set
![Page 32: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/32.jpg)
Kinds of Constraints
What kind of constraints can be defined in the ER Model?
Cardinality ConstraintsParticipation ConstraintsTogether called “Structural Constraints”
Constraints are represented byConstraints are represented byspecific notation in the ER diagramspecific notation in the ER diagram
![Page 33: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/33.jpg)
The “Cardinality Ratio” for a binary relationship specifies the number of relationship instances that an entity can participate in– Works-In is a binary relationship– Participating entities are DEPARTMENT : EMPLOYEE– One department can have Many employees - Cardinality Ratio is 1 : N
Employees
Works_InWorks_In
Departments
Possible Cardinality Ratios
![Page 34: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/34.jpg)
Possible Cardinality Ratios
1–to-1 (1 : 1)– Both entities can participate in only one relationship instance
1-to-Many, Many-to-1(1 : N, N : 1)– One entity can participate in many relationship instances
Many-to-Many (N: M)– Both entities can participate in many relationship instance
.
.
.....1- to - Many1- to - Many
.
.
.
.
.
.
.
Many - to - Many - to - 11
.
.
.
.
.
.
1-to-11-to-1
.
.
.....Many-to-ManyMany-to-Many
![Page 35: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/35.jpg)
Example Cardinality Constraints
How many Employees can work in a Department? One employee can work in only one departmentHow many Employees can be employed by a Department? One department can employ many employeesHow many managers can a department have? One department can have only one managerHow many departments can an employee manage? One employee can have manage only one department
![Page 36: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/36.jpg)
Representing Cardinality
One employee can work in only one departmentOne department can employ many employeesOne department can have only one manager
One employee can manage only one department
N 1
1 1
Employees
Works_InWorks_In
DepartmentDepartmentss
ManagesManages
![Page 37: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/37.jpg)
Existence Dependency
Existence dependency indicates whether the existence of an entity depends on its relationship to another entity via the relationship type– Every employee must work for a department - EMPLOYEE is existentially dependent on DEPARTMENT via the Works In relationship type
EmployeesEmployees
Works_InWorks_In
DepartmentDepartmentss
![Page 38: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/38.jpg)
Kinds of participating constraints
TOTAL Participation (Existence Dependency)Constraint : Every employee must work for a department
PARTIAL ParticipationConstraint : Not every employee is a manager
![Page 39: Entity Relationship Diagrams](https://reader036.vdocuments.mx/reader036/viewer/2022070500/56816827550346895dddb8a6/html5/thumbnails/39.jpg)
Representing Participation
Every employee must work for a department
Every department must have a managerEvery department must have employees
Not every employee is a manager
N 1
1 1
EmployeesEmployees
Works_In
DepartmentDepartmentss
Manages