Professional Documents
Culture Documents
BITS Pilani
Hyderabad Campus
Dr.R.Gururaj
CS&IS Dept.
Lecture Session-2
Content
ER Model Steps in Database Design Process Entities, Attributes, and Associations ER Notations Enhanced ER modeling Super-class and sub-class representation
31/07/2013
31/07/2013
ER Modeling
ER Model is a popular high-level (conceptual) data model. It is an approach to designing Semantic Conceptual schema of a Database. ER model allows us to describe the data involved in a real-world environment in terms of objects and their relationships, which are widely used in design of database. ER model provides preliminary concepts or idea about the data representation which is later modified to achieve final detailed design. Important concepts/notions used in ER modeling areEntity is an object in real-world or some idea or concept which can be distinguished from other objects. Ex.: person, school, class, department, weather, salary, temperature etc. Entity has independent existence. Each entity belongs to an Entity type that defines the structure. Entity Set is a Collection of similar objects.
3 31/07/2013 SSZG 518 Database Design & Applications BITS Pilani, Hyderabad Campus
Concepts used in ER
Attribute: reflects a property of an object or entity. We have following types of attributes. > Simple attribute > Composite attribute > Single valued attribute > Multi-valued attribute > Derived attribute > Stored attribute Candidate Key (simply called a key): Is an Attribute of an entity type whose value can uniquely identify an entity in a set. Primary key: one of the candidate keys can become PK of an entity type. Alternate keys: The candidate keys other than the PK, are known as alternate keys.
31/07/2013
Concepts used in ER
Relationship: The association between entities is known as relationship. Domain of an attribute: The set of possible values is known as domain of an attribute
31/07/2013
Notations used in ER
Notations used in ER modeling are shown below.
Entity Type
Relationship Type
Attribute
31/07/2013
Notations used in ER
Key Attribute
Multivalued Attribute
Composite Attribute
Derived Attribute
31/07/2013
Notations used in ER
E1
E2
Total Participation of E1 in R
1 E1
E2
(min, max) R E
31/07/2013
Relationships in ER
Relationships
Manager Manages Employee
Manager
Manages
Employee
Degree of a Relationship If there are two entity types involved it is a binary relationship type If there are three entity types involved it is a ternary relationship type
Sales Assistant Sells Product
Manager
Manages
Employee
Customer
Relationships in ER
Cardinality of a relationship Relationships are rarely one-to-one. For example, a manager usually manages more than one employee. This is described by the cardinality of the relationship, for which there are four possible categories.
1
Man
is married to
Women
Manages
m Employee
Manager
Student
Studies
1 Course
Lecturer
Teaches
n Student
10
31/07/2013
Relationships in ER
Participation Constraint If all the entities of an entity type are involved in the relationship then that entity types involvement said to be total in that relationship. In the below relationship if each employee is associated with at least one dept. Then the participation of EMP is total. Here, EMP works for DEPT. If, only few entities of the set are involved the participation is partial.
E1 R E2
DEPT
Association Role:
* EMP
1 DEPT
Multiplicity
EMP
Works_for
DEPT
11
31/07/2013
Number
(1, 1)
Salary
Employee
(4, N) department
Number of Employees
Name
Location
Ssn Bdate
EMPLOYEE
DEPARTMENT
Start Date
(1, 1)
MANAGES
Hours
CONTROLS
(0, N) Employee
DEPENDENTS_OF
WORKS_ON
(1, N) Project
Name
Dependent (1, 1)
DEPENDENT
Number Location
Name
12
31/07/2013
31/07/2013
Introduction to EER
Why EER Some applications like GIS, CAD/CAM, Telecommunication Have more complex requirements than normal database applications. To meet the requirements additional modeling concepts were incorporated into Conceptual data modeling such as ER modeling. The result is EER, stands for Extended ER modeling or Enhanced ER modeling
EER Basics
Additional concepts:
Subclasses/super classes Specialization/generalization Attribute and relationship Inheritance
These are fundamental to conceptual modeling.
14
31/07/2013
Subclasses in EER
Subclass of an Entity type
MANAGER
EMPLOYEEs who are managers
SALARIED_EMPLOYEE, HOURLY_EMPLOYEE
Based on the EMPLOYEEs method of pay
EER diagrams extend ER diagrams to represent these additional subgroupings, called subclasses or subtypes
15 31/07/2013 SSZG 518 Database Design & Applications BITS Pilani, Hyderabad Campus
EER Notations
16
31/07/2013
17
31/07/2013
Note: An entity that is member of a subclass represents the same real-world entity as some member of the superclass:
The subclass member is the same entity in a distinct specific role An entity cannot exist in the database merely by being a member of a subclass; it must also be a member of the superclass A member of the superclass can be optionally included as a member of any number of its subclasses
18 31/07/2013 SSZG 518 Database Design & Applications BITS Pilani, Hyderabad Campus
A salaried employee who is also an engineering manager belongs to the three subclasses:
o MANAGER, o ENGINEER, and o SALARIED_EMPLOYEE
20
31/07/2013
Specialization in EER
Specialization is the process of defining a set of subclasses of a superclass
The set of subclasses is based upon some distinguishing characteristics of the entities in the superclass Example: {SECRETARY, ENGINEER, TECHNICIAN} is a specialization of EMPLOYEE based upon job type. May have several specializations of the same superclass
21
31/07/2013
Specialization
Example: Another specialization of EMPLOYEE based on method of pay is {SALARIED_EMPLOYEE, HOURLY_EMPLOYEE}.
Superclass/subclass relationships and specialization can be diagrammatically represented in EER diagrams Attributes of a subclass are called specific or local attributes.
For example, the attribute TypingSpeed of SECRETARY
22
31/07/2013
Generalization
Generalization is the reverse of the specialization process Several classes with common features are generalized into a superclass;
Original classes become its subclasses
23
31/07/2013
24
31/07/2013 SSZG
Constraints
Two basic constraints can apply to a specialization/generalization:
o Disjointness Constraint: o Completeness Constraint:
25
31/07/2013
Disjointness Constraint:
Specifies that the subclasses of the specialization must be disjoint:
an entity can be a member of at most one of the subclasses of the specialization
Completeness Constraint:
Total specifies that every entity in the superclass must be a member of some subclass in the specialization/generalization Shown in EER diagrams by a double line Partial allows an entity not to belong to any of the subclasses Shown in EER diagrams by a single line
27
31/07/2013
Note: Generalization usually is total because the superclass is derived from the subclasses.
28 31/07/2013 SSZG 518 Database Design & Applications BITS Pilani, Hyderabad Campus
29
31/07/2013 SSZG
30
31/07/2013
Summary
32
31/07/2013