Comp 1350 Lecture Week2 ER
Comp 1350 Lecture Week2 ER
WEEK-2
3
Business Rules
30/07/2021
4
A Good Business Rule Is:
5
ER Model Components
7/30/21
6
ER Model Components- Other
definitions
• Entities:
• Entity–person, place, object, event, concept
• Relationships:
• Relationship–link between entities
• Relationship type–category of relationship…link between entity
types
• Attributes:
• Properties or characteristics of an entity or relationship type (often
corresponds to a field in a table)
7
An Entity
• 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
8
Types of Entities
Strong entity
• exists independently of other types of entities
• has its own unique identifier known as primary identifier
• Note: please do not use the term ’Primary Key’ here
Weak entity
• depends on a strong entity to exist.
• doesn’t have its own primary identifier
Associative entities
• to be discussed later
9
Example of a weak identity and its identifying relationship
11
Required vs. Optional Attributes
Required – must have a value for Optional – may not have a value
every entity (or relationship) for every entity (or relationship)
instance with which it is associated instance with which it is associated
12
Simple vs. Composite Attributes
The address is
broken into
component parts
A composite attribute
13
Multi-valued and Derived Attributes
Multivalued – may take on more than Derived – values can be calculated from
one value for a given entity (or related attribute values (not physically
relationship) instance stored in the database)
Multivalued Derived
an employee can Calculated
have more than one from date
skill employed
and current
date
15
Suggestions for Identifiers
• Choose Identifiers that
• Will not change in value
• Will not be null
• Avoid intelligent identifiers (e.g., containing locations or people
that might change)
• Substitute new, simple keys for long, composite keys
16
Naming Attributes
• Name should be a singular noun or noun phrase
• Name should be unique
• Name should follow a standard format
• e.g. Entity name |Attribute name
• Similar attributes of different entity types should use the same
qualifiers and classes
17
Relationships
• A relationship is modeled as lines between entities
• Relationships can have attributes (in many-many
relationships)
• These describe features pertaining to the association
between the entities in the relationship
• Two entities can have more than one type of relationship
between them (multiple relationships)
• Associative Entity–combination of relationship and entity
18
Relationship types and instances
Relationship
example
Relationship
instances
with
instances of
entities
20
Degree of relationships – from Figure 2-2
• One-to-One
• Each entity in the relationship will have exactly one related entity
• One-to-Many
• An entity on one side of the relationship can have many related
entities, but an entity on the other side will have a maximum of one
related entity
• Many-to-Many
• Entities on both sides of the relationship can have many related
entities on the other side
22
Examples of Unary relationships
26
Associative Entities
• An entity–has attributes
• A relationship–links entities together
• When should a relationship with attributes instead be an associative
entity?
• All relationships for the associative entity should be many
• The associative entity could have meaning independent of the other
entities
• The associative entity preferably has a unique identifier, and should
also have other attributes
• The associative entity may participate in other relationships other
than the entities of the associated relationship
• Ternary relationships should be converted to associative entities
27
References
ITEC800 - Week 5 28