Entity Relationship Diagram
A real-world thing either animate or
inanimate that can be easily identifiable and distinguishable. For example, in
a school database, student, teachers, class and course offered can be
considered as entities. All entities have some attributes or properties that
give them their identity.
An entity set is a collection of
similar types of entities. Entity set may contain entities with attribute
sharing similar values. For example, Students set may contain all the student
of a school; likewise Teachers set may contain all the teachers of school from
all faculties. Entities sets need not to be disjoint.
Attributes
Entities are represented by means of
their properties, called attributes. All attributes have values. For example, a
student entity may have name, class, age as attributes.
There exists a domain or range of
values that can be assigned to attributes. For example, a student's name cannot
be a numeric value. It has to be alphabetic. A student's age cannot be
negative, etc.
Types
of attributes:
- Simple attribute:
Simple
attributes are atomic values, which cannot be divided further. For example,
student's phone-number is an atomic value of 10 digits.
- Composite attribute:
Composite
attributes are made of more than one simple attribute. For example, a student's
complete name may have first name and last name.
- Derived attribute:
Derived
attributes are attributes, which do not exist physical in the database, but
there values are derived from other attributes presented in the database. For
example, average salary in a department should be saved in database instead it
can be derived. For another example, age can be derived from date _of _birth.
- Single-valued attribute:
Single
valued attributes contain on single value. For example: Social Security Number.
- Multi-value attribute:
Multi-value
attribute may contain more than one value. For example, a person can have more
than one phone numbers, email addresses etc.
These attribute types can come
together in a way like:
- simple single-valued attributes
- simple multi-valued attributes
- composite single-valued attributes
- composite multi-valued attributes
Entity-set
and Keys
Key is an attribute or collection of
attributes that uniquely identifies an entity among entity set.
For example, roll number of a
student makes her/him identifiable among students.
- Super Key: Set of attributes (one or more) that collectively identifies an entity in an entity set.
- Candidate Key: Minimal super key is called candidate key that is, supers keys for which no proper subset are a super key. An entity set may have more than one candidate key.
- Primary Key: This is one of the candidate key chosen by the database designer to uniquely identify the entity set.
Relationship
The association among entities is
called relationship. For example, employee entity has relation works at with
department. Another example is for student who enrolls in some course. Here,
Works at and Enrolls are called relationship.
Relationship
Set:
Relationship of similar type is
called relationship set. Like entities, a relationship too can have attributes.
These attributes are called descriptive attributes.
Degree
of relationship
The number of participating entities
in an relationship defines the degree of the relationship.
- Binary = degree 2
- Ternary = degree 3
- n-ary = degree
Mapping
Cardinalities
Cardinality defines the number of entities in one entity set which can
be associated to the number of entities of other set via relationship set.
- One-to-one: one entity from entity set A can be associated with at most one entity of entity set B and vice versa.
[Image: One-to-one relation]
- One-to-many: One entity from entity set A can be associated with more than one entities of entity set B but from entity set B one entity can be associated with at most one entity.
[Image: One-to-many relation]
- Many-to-one: More than one entities from entity set A can be associated with at most one entity of entity set B but one entity from entity set B can be associated with more than one entity from entity set A.
[Image: Many-to-one relation]
- Many-to-many: one entity from A can be associated with more than one entity from B and vice versa.
No comments:
Post a Comment