Professional Documents
Culture Documents
Chapter 3-ER (Part 1)
Chapter 3-ER (Part 1)
Systems
2
The E-R Model: over view
An entity-relationship model (or E-R model) is a
detailed, logical representation of the data for an
organization or for a business area.
The E-R model is expressed in terms of entities in the
business environment, the relationships (or
associations) among those entities, and the attributes
(or of both the entities and their
properties)
relationships. is normally expressed as an entity-
An E-R model
relationship diagram (or E-R diagram, or simply ERD),
which is a graphical representation of an E-R model.
3
The E-R Model: over view….
It provides useful concepts that allow us to move from an
informal description of what users want from their database
to a more detailed and precise, description that can be
implemented in a DBMS.
4
The E-R Model
5
The E-R Model
Entity
PRODUCT
ORDER
ITEM
SUPPLIER
SHIPMENT T
6
Drawing tools
Microsoft Visio
Oracle Designer
All Fusion ERWin
Power Designer
7
Building Blocks/ Component of the E-R model
world object.
Relationship: the association between Entities
8
Building Blocks of the Relational Data
Model
Entity: A person, place, object, event, or concept in the
user environment about which the organization wishes to
maintain data.
Each entity within the entity type will have the same set
and number of attributes, but in general different attribute
values.
12
Types of Attributes
1. Simple (atomic) Vs Composite attributes
2. Single-valued Vs multi-valued attributes
3. Stored vs. Derived Attribute
4. Null Values
13
Types of Attributes…
(1) Simple (atomic) Vs Composite attributes
Simple : contains a single value (not divided into sub
parts)
E.g. Age, gender
Composite: Divided into sub parts (composed of other
attributes)
E.g. Name, address
14
Types of Attributes …
(2) Single-valued Vs multi-valued attributes
Single-valued : have only single value(the value
may change but has only one value at one time)
E.g. Name, Sex, Id. No. color_of_eyes
Multi-Valued: have more than one value
E.g. Address, dependent-name
Person may have several college degrees
15
Types of Attributes…
Stored vs. Derived Attribute
Stored : not possible to derive or compute
Profit (earning-cost)
16
Types of Attributes…
Null Values
NULL applies to attributes which are not applicable or
17
Relationships
Relationships are the glue that holds together the
various components of an E-R model.
Intuitively, a relationship is an association
representing an interaction among the instances of one or
more entity types that is of interest to the
organization.
Thus, a relationship has a verb phrase name.
18
Relationship type and instances
Relationship type: A meaningful association between
(or among) entity types.
Relationship instance: An association between
(or
among) entity instances where each relationship
instance includes exactly one entity from each
participating entity type.
19
Relationship type and instances
(a) Relationship type (Completes)
20
Relationship type and instances
21
Degree of a Relationship
Degree: The number of entity types that participate in a
relationship.
Unary relationship: A relationship between the
instances of a single entity type.
Binary relationship: A relationship between the
instances of two entity types.
Ternary relationship: A simultaneous relationship
among the instances of three entity types.
22
Cardinality Constraints
Cardinality can be :-
ONE-TO-ONE:one tuple is associated with only one other
tuple.
e.g. Building - Location,
23
Cardinality Constraints
Cardinality can be :-
MANY-TO-MANY: one tuple is associated with many other
tuples and from the other side, with a different role name
one tuple will be associated with many tuples.
e.g. Author - Book
24
Cardinality Constraints
Example
25
Problem in ER Modeling
To be Continued…
26
Problem in ER Modeling
While designing the ER model one could face a problem on
the design which is called a connection traps.
Chasm Trap:
27
Problem in ER Modeling
1.Fan trap:
Occurs where a model represents a relationship between
29
1.Fan trap …
Problem: Which car (Car1 or Car3 or Car5) is used by
Employee 6 Emp6 working in Branch 1 (Bra1)?
Thus from this ER Model one can not tell which car is used
by which staff since a branch can have more than one car
and also a branch is populated by more than one employee.
30
1.Fan trap…
To avoid the Fan Trap problem we can go for restructuring of
the E-R Model. This will result in the following E-R Model.
31
2.Chasm Trap
Occurs where a model suggests the existence of a
relationship between entity types, but the path way does not
exist between certain entity occurrences.
32
2.Chasm Trap…
Example
33
2.Chasm Trap…
Problem: How can we identify which BRANCH is
responsible for which PROJECT? We know that whether the
PROJECT is active or not there is a responsible BRANCH.
34
2.Chasm Trap…
The solution for this Chasm Trap problem is to add
another relationship between the extreme entities
(BRANCH and PROJECT)
35
Constraints
Domain Integrity: No value of the attribute should be
beyond the allowable limits
Entity Integrity: In a base relation, no attribute of a
primary key can be null
Referential Integrity: If a foreign key exists in a relation,
either the foreign key value must match a candidate key in
its home relation or the foreign key value must be null
foreign key to primary key match- ups
Enterprise Integrity: Additional rules specified by the
users or database administrators of a database are
incorporated
36
Key constraints
Key constraints
If tuples are need to be unique in the database, and then we need
to make each tuple distinct. To do this we need to have relational
keys that uniquely identify each relation.
Super Key: an attribute or set of attributes that
uniquely identifies a tuple within a relation.
Candidate Key: a super key such that no proper subset of that
collection is a Super Key within the relation. A candidate key
has two properties:
1.Uniqueness
2.Irreducibility
If a candidate key
consists of more
than one attribute 37
Key constraints
Primary Key: the candidate key that is selected to
identify tuples uniquely within the relation.
The entire set of attributes in a relation can be
considered as a primary case in a worst case.
Foreign Key: an attribute, or set of attributes, within
one relation that matches the candidate key of
some relation.
A foreign key is a link between different relations to
create the view or the unnamed relation
38
Relational languages and
views
The languages in relational database management
systems are the DDL, VDL and the DML that are
used to define or create the database and perform
manipulation on the database.
39
Relational languages and
views
1. Base Relation
A Named Relation corresponding to an entity in the
conceptual schema, whose tuples are physically stored in
the database.
2. View
Is the dynamic result of one or more relational operations
41
Symbols to draw ERD
42
Symbols to draw ERD…
43
ERD example
44
Question?
45