ENTITY- RELATIONSHIP MODEL :( E- R MODEL):
An entity- relationship 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
among those entities, and the attributes of both entities and their relationships.
An E-R model is normally expressed as an E-R diagram.
Entities:
An entity is a person, place, object, event, or concept in the user environment about which the
organization wishes to maintain data. Some examples
Person: Employee, student, patient
Place: city, country
Object: machine, building
Event: sale, registration
Concept: account, course
Entity is denoted using a rectangle box in the E-R diagram.
Entity STUDENT
Entity type and Entity Instance:
An Entity type is a collection of entities that share common properties or characteristics.
Ex: Employee, Student
An Entity instance is a single occurrence of entity type. Ex: John
Strong Entity and Weak Entity types:
A strong entity type is one that exists independently of other types.
Example: SUDENT, EMPLOYEE, AUTOMOBILE and, COURSE
A Weak entity type is an entity type whose existence depends on some other entity type. The
entity type on which the weak entity type depends is called as the Identifying Owner.
Dependent is the entity type that is depending on Employee type, so Dependent is the weak
Entity type. We will denote the weak entity using double rectangle box.
DEPENDENT
ATTRIBUTES:
An attribute is property of an entity type that is of interest to the organization
Ex: STUDENT: student_ID, Student _Name, Address, Phone_Number
EMPLOYEE: Employee_Id, Employee_Name, Address, Skill
Attributes are denoted using ellipse in the E-R Diagram
Student_ID Student_Name
STUDENT
Simple versus Composite Attributes:
A Composite Attribute is an attribute that can be broken down into component parts. Ex: Address,
address can be divided into h_no, street_name, city, state
Address
H_No Street_Nam City
A Simple Attribute is an attribute that cannot be broken down into smaller components.
Ex: age for student entity.
Multivalued Attributes:
A Multivalued attribute is an attribute that may take more than one value for a given entity instance.
We indicate a multivalued attribute with an ellipse with double lines.
Ex: Skill for Employee Entity, because skill is having more than one value like C, C++, Java etc.
STUDENT Skill
A derived attribute is an attribute is an attribute whose values can be calculated from related attribute
values. It is denoted using dashed ellipse.
An Identifier is an attribute that uniquely identifies individual instances of entity type. Ex: Student_ID
It is denoted as underlined attribute
Student_ID Student_Name
STUDENT
A Composite Attribute is an Identifier that consists of a composite attribute. Ex Flight_ID
Flight_Number Date
Student_Name
Flight_ID
FLIGHT
RELATIONSHIPS
A relationship is an association among the instances of one or more entity types that is of interest of
the organization.
Relationship Type is a meaningful association between entity types. A relation type is denoted by a
diamond symbol containing the name of the relationship.
Course_I Course_Title Prerequisite
Employee_id Name dD
EMPLOYEE COURSE
Complete
s
Relationship Instance is an association between entity instances, where each relationship instance
includes exactly one entity from each participating entity type.
Ex: Employee Course
Venkat Java
Ramu C++
John UNIX
Associative Entity:
Associative entity is an entity type that associates the instances of one or more entity types and
contains attributes that are peculiar to the relationship between those entity instances. An associative
entity is represented with the diamond relationship symbol enclosed within the entity box.
Associative entity
Course_I Course_Title Prerequisite
Employee_id Name
Ceritficate_name
EMPLOYEE ` COURSE
Certificat
Degree of Relationship:
The degree of relationship is the number of entity type that participates in that relationship.
Unary Relationship: it is a relationship between the instances of a single entity type. These are also
called recursive relationship
Ex:
EMPLOYEE
Manage
Binary Relationship: the relationship between two entity types.
Student Has Book
Ternary Relationship: the relationship among three entity types.
PART
` `
VENDOR Supply WAREHOUSE
Schedul
Shipping_mode Unit_cost
Data models use three types of relationships:
1) One- to – many (1: M or 1...*) relationship: A painter paints many different paintings, but each
one of them is painted by only one painter. Thus the one painter is related to many paintings.
Therefore database designers label the relationship PAINTER paints PAINTINGS as 1: M.
2) Many- to – many (M: N or *...*) relationship: A student can classes and each class can be taken
by many students, thus database designers label the relationship STUDENT takes CLASS as M: N
(Many -to -many)
3) One- to – one (1: 1 or 1...1) relationship: A retail company’s management structure may require
that each of its stores be managed by a single employee. In turn, each store manager, who is an
employee, manages only a single store. Therefore, the relationship EMPLOYEE manages STORE is
1:1.
Relationships are bidirectional.
Constraints: A constraint is a restriction placed on the data. Constraints are important because they
help to ensure data integrity. Constraints are normally expressed in the form of rules.
E- R Model Notation:
Strong entity Associative entity
Weak entity Attribute
Relationship Multivalued attribute
Identifying
relationship Derived Attribute
Mandatory one
Unary
Binary Mandatory many
Optional one
Optional many
Ternary
Enhanced E-R Model:
Conceptual Data Models:
Objects: object represent things that are important to users in the portion of reality we want to model.
Ex: People, Automobiles, trees and books
Object set: A set of things of the same kind.
Object Instance: a particular member of an object set
The object set PERSON The object set
name
Person
+
An object instance
Lexical Object Set: An object set consisting of instances that can be printed. Ex: NAME
Abstract Object Set: An object set consisting of instances that cannot be printed. Ex: PERSON
An abstract object instance would be represented by an internal number which has no meaning outside
the system. This internal number is sometimes called an Object identity, or a Surrogate key.
Surrogate key: A unique computer system identifier for an abstract object instances; it has no
meaning outside the computer system.
Specialization: An object set that is a subset of another object set. Ex: PERSON
Generalization: An object set that is superset of another object set. EX: MAN
PERSON
PERSON
MAN
MAN
TWO POINTS REPRESENTING THE SAME INSTANCE
PERS
ON
George
MAN
George
Relationship: A linking between instances of two object sets.
Cardinality constraints: The number of instances of one object set or entity associated to a single
instance of other object set or entity.
Minimum Cardinality: The minimum number of instances of one object set or entity associated to a
single instance of other object set or entity.
Maximum Cardinality: The maximum number of instances of one object set or entity associated to a
single instance of other object set or entity
If we assume each married person has only one spouse, the cardinality of the IS-MARRIED-TO
relationship is one in each direction.
Here the maximum cardinality is One and Minimum Cardinality is Zero in both directions.
This is represented as follows
MAN 0, 1 IS- 0, 1 WOMAN
MARRIE
D- TO
1, 1 1,*
SUPERVISOR SUPERVISE WORKER
S
Here the maximum and minimum cardinality is One in supervisor direction, one and many in worker
direction.
Cardinalities of Generalization/ Specialization
PERS
ON
1,1
0, 1
MAN
Functional Relationship: a relationship having s maximum cardinality one in at least one direction.
One- to – one (1: 1 or 1-1) relationship: the relationship cardinalities of one in both directions,
One- to – many (1: M or 1-*) relationship: The relationship cardinalities one in one direction and
many in other direction.
Many- to – many (M: M or *-*) relationship: relationship cardinalities of many in both directions.
Cardinality Notation Example
One- one 1:1 or 1-1 A husband has one wife.
A wife has one husband.
(The marriage relationship is one-one)
One – many 1:* or 1-* An employee is in one department
A department has many employees.
(The employment relationship is one- many)
Many- many *:* or *-* A student takes many courses.
A course has many students.
(The enrollment relationship is many- many)
Attribute is functional relationship from an object set to another set.
Key is a value that can always be used to uniquely identify an object instance.
External Key is a set of lexical attributes whose values always identify a single object instance.
An External key is called as Identifier
Inherit: The property of a specialization set that causes it to have all the attributes of its generalization
set.
SPECIALIZATION INHERIT ATTRIBUTES
Name
SS# Addr
ess
PERSO
N
SPOUS
E
MARRIE
D
PERSON
MARRIED PERSON is a specialization of PERSON. Thus, a married person has a name,
social security number, address, and so on. So the MARRIED PERSON object set inherits these
inherits attributes from the PERSON object set. In addition, the specialization object set can have
PERSON
MARRIED
PERSON
attributes of its own. For example, SPOUSE would be an attribute of MARRIED PERSON, but not of
PERSON.
INHERTITING RELATIONSHIPS
FOR
WORKS-
John Doe XYZ Company
John Doe
COMPANY
Aggregation:
Aggregate: A relationship viewed as an Object set.
A Higher- level relationship: A relationship which involves three or more object sets.
Anniversary
EX: date
MARRIED- COUPLE
MARRIED IS-
MARRIED
MAN MARRIED- WOMAN
TO
In the above figure each man and woman who are related to is- married- to relationship
constitute a married couple, which itself an object. As such married couple can have its own
attributes, such as anniversary date, address. So here married couple is an aggregate.
QUA
NTI
Another ex: TY
* *
PRODUCT IS-SOLD-IN COUNTRY
Q
U
A
N
Y
T
T
I
USING TWO BINARY RELATIONSHIPS
* *
PRODUCT IS-SOLD-IN COUNTRY
*
SOLD-ON
*
DATE
Q
U
A
N
Y
T
T
I
USING THREE WAY RELATIONSHIP
* SOLD *
PRODUCT COUNTRY
*
DATE