Data Models - ER2
Data Models - ER2
Entity-Relationship Model
An ER Model is a high level description of the data and the relationships among the data, rather how
data is stored. Some features of E-R Model are:
1. The E-R diagram used for representing E-R Model can be easily converted into relations(tables) in
relational model.
2. The E-R Model is used for the purpose of good database design by the database developer so as
o use that data model in various DBMA.
3. It is a top-down approach to database design.
4. It gives the precise understanding of the nature of data and how it is used by an enterprise.
5. It is very simple, non technical, free of ambiguities and easy to understand by various types of
users, programmers and designers because a specific standards are used for their representation.
E-R Diagram
• Entity relationship model defines the conceptual view of
database.
• It works around real world entity and association among
them.
E-R Model Terminology
ENTITY
• A real-world thing either animate or inanimate that can be easily identifiable and distinguishable.
• Objects about which information can be stored.
• For example, in a school database, student, teachers, class and course offered can be considered as entities.
• Properties of Entity :
1. Entity is represented by set of properties called attributes.
2. Entity is atomic and cannot be broken down into smaller pieces.
3. Entity is an instance of entity type so it is represented in E-R diagrams a rectangular box enclosing its name.
ENTITY TYPE
• An entity type is a collection of entities that have the same attributes but different values.
• Properties of Entity Type:
1. An entity is an instance of entity type.
2. An entity type is identified by its name and properties.
3. An entity type is represented by ER diagram as a rectangular box enclosing the entity type.
ENTITY SET
An entity set is a collection of all instances of a particular entity type at any point of time in the
database. Each entity set is referred by its name and attribute values.Its name is same as that of
entity type.
ATTRIBUTES
Entities are represented by means of their properties, called attributes.
– For example, a student entity may have name, class, age as attributes.
Properties of Attributes
1. The attributes of an entity should be unique.
2. The attributes should uniquely identify the entity.
3. The set of permitted values for each attribute is known as its domain from where its values are
chosen.
4. An attribute of an entity is represented in ER diagram as an ellipse attached to a relevant entity
by a line and labelled with entity name.
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 data_of_birth.
• Single-valued attribute:
Single valued attributes is the one that has only a single value for a particular entity.
– For example: RollNo.
• Multi-value attribute:
Multi-value attribute is an attribute that holds multiple values for a particular single
entity.
– For example, a person can have more than one phone numbers,
email_addresses etc.
Relationship
• DEGREE OF RELATIONSHIP
• The number of participating entities in an relationship defines the degree of the relationship or Total number of
attributes or columns of a relation is known as the degree of the relation.
• Unary – When association exists within a single entity type. The degree of unary relationship is 1. It is sometimes
called as Recursive Relationship.
• Binary - When association exists between two entity types. The degree of binary relationship is 2.
• Ternary – When association exists among three entity types. The degree of ternary relationship is 3. It is rarely used
in real world. If it exists, is should be decomposed into one or more binary relationships.
• Quaternary - When association exists among four entity types. The degree of Quaternary relationship is 4.
Connectivity of Relationship
• Connectivity of relationship means how many instances of
one entity are associated with how many instances of other
entity in a relationship. It describes the mapping of
associated entity instances in the relationship.
Mapping Cardinalities:
• Entity
• Entities are represented by means of rectangles. Rectangles
are named with the entity set they represent.
• Attributes
Cardinality of Relationship
• The total number of rows or tuples in a table is referred as
Cardinality of a relation.
• Cardinality of a relationship quantifies the relationship
between entities by measuring how many instances of one
entity type are related to a single instance of another.
• The actual count of elements associated with the
connectivity is called Cardinality.
Direction of Relationship
• The direction of the relationship is the line connecting the
two entities related to each other by a relationship.
• The entity from where the relationship starts is the parent
entity and the entity where the relationship ends is called the
child entity.
• The type of relation is determined by the line connecting the
entities and the relationship components.
relationship and cardinality
• One-to-one
• When only one instance of entity is associated with the
relationship, it is marked as '1'. This image below reflects that
only 1 instance of each entity should be associated with the
relationship. It depicts one-to-one relationship.
• One-to-many
• When more than one instance of entity is associated with the relationship, it is
marked as 'N'. This image below reflects that only 1 instance of entity on the left
and more than one instance of entity on the right can be associated with the
relationship. It depicts one-to-many relationship.
• Many-to-one
• When more than one instance of entity is associated with the
relationship, it is marked as 'N'. This image below reflects that more
than one instance of entity on the left and only one instance of entity
on the right can be associated with the relationship. It depicts many-
to-one relationship
• Many-to-many
• This image below reflects that more than one instance of entity on the
left and more than one instance of entity on the right can be
associated with the relationship. It depicts many-to-many relationship.
Participation Constraints
SUBCLASS : A subclass or higher level entity sets includes distinct subclasses also known as low level entity sets
that has a distinct role on the basis of some distinguishing characteristics of the entities in the superclass. Eg-
EMPLOYEE entity can have subclass such as Manager, Secretary, Technician, Engineer and so on. The EMPLOYEE
entity acts as a superclass and other entities acts as a subclass. The Relationship between superclass and one of
its subclasses is known as superclass/subclass relationship.
http://www.tutorialspoint.com/dbms/
http://www.tutorialspoint.com/dbms/
Specialization
• Specialization is a process of defining one or
more subclass entity sets from the
superclass entity sets based on some unique
attribute specific to the subclass entity set.
• Specialization is a process, which is opposite
to generalization. In specialization, a group
of entities is divided into sub-groups based
on their characteristics.
• In a company, a person can be identified as
employee, employer, customer or vendor
based on what role do they play in company.
Properties of Specialization
1. Specialization exists only when there exists specific or unique attributes of the
subclass entity set. If there is no unique attributes of subclass entity set then
there is no need of specialization.
2. It is needed when some relationship types may be participated only by the entity
sets which are members of that subclass. Eg-MANAGER relationship exists
between Manager subclass and relating it to Project entity type.
3. In the EER diagram, specialization is represented by a triangle component
labelled “IS A”.
4. It is top down process.
5. It maximizes the difference between the entity sets by identifying unique
attributes of each subclass.
Generalization
• It is reverse of Specialization. There may exist a number of lower level entity sets
that share the same attributes and participate in the same relationship sets. So we
generalize these low level entity sets into a single higher level entity set based on
these common attributes and relationships.
• Generalization is a process of defining a single higher level entity set from a set of
specialized low level entity sets or identification of generalized superclass entity set
from original subclass entity sets.
• In generalization, a number of entities are brought together into one generalized
entity based on their similar characteristics. For an example, pigeon, house
sparrow, crow and dove all can be generalized as Birds.
Properties of Generalization
1. Generalization exists only when the distinct low level entity sets have
some common attributes and same relationship types.
2. It is a bottom up approach.
3. It minimizes the difference between the low level entity sets by
creating a single high level entity set using common attributes.
4. Shared attributes are not repeated.
5. In the EER diagram, generalization is represented by a triangle
component labelled “IS A”.
Aggregation
• One of the main limitations of ER diagram is that it cannot express Relationship
among Relationships.
• So in order to represent these relationship among relationships, we combine the
entity sets and there relationships to form a higher level entity set. This process of
combining entity sets and their relationship to form a higher level entity set so as
to represent relationship among relationship is known as Aggregation.
• Aggregation is an abstraction in which relationship sets are ‘treated as higher level
entity sets used for the purpose of participating in other relationship.
For Example, Employee working for a project may require some machinery. So, REQUIRE relationship is
needed between relationship WORKS_FOR and entity MACHINERY. Using aggregation, WORKS_FOR
relationship with its entities EMPLOYEE and PROJECT is aggregated into single entity and relationship
REQUIRE is created between aggregated entity and MACHINERY.
Inheritance
http://www.tutorialspoint.com/dbms/
http://www.tutorialspoint.com/dbms/
http://www.tutorialspoint.com/dbms/
http://www.tutorialspoint.com/dbms/
Hierarchical Model
• First hierarchical data model was designed by IBM and North
American Rockwell in 1950.
• Records are arranged in tree like structure, and are linked
with their superior records on which they are dependent and
to them which are dependent on them.
• One to many relationship.
Operations on Hierarchical Model
• Insert
• Update
• Delete
• Retrieval of information
Advantages/ Disadvantages
• Advantages:
• Simplicity
• Data security
• Data integrity
• Efficiency
• Disadvantages
• Implementation complexity
• Database management problem
• Lack of structural independence
Network Model
• Network model replace the tree structure with graph.
• Advantages:
– Conceptual simplicity
– Capable to handle more relationship typed: 1:N,N:N
– Data integrity
– Data independence
• Database standards:
– ANSI in 1970
• Disadvantages :
– System complexity
– Operational anomalies
– Absence of structural independence