Dbms Entity

Download as pdf or txt
Download as pdf or txt
You are on page 1of 40

SE IT, Semester – III

Module 02
The Entity-Relationship Model

Prof. Nilesh Mali


IT Dept, VPPCOE&VA College
Syllabus
Conceptual Modeling of a database, The
Entity Relationship (ER) Model, Entity
Type, Entity Sets, Attributes and Keys,
Relationship Types, Relationship Sets,
Weak entity Types Generalization,
Specialization and Aggregation, Extended
Entity-Relationship (EER) Model.

Self-learning Topics: Design an ER model


for any real time case study
Database Design
• Why do we need it?
– Agree on structure of the database before
deciding on a particular implementation.

• Consider issues such as:


– What entities to model
– How entities are related
– What constraints exist in the domain
– How to achieve good designs
Database Design
ERM and ERD
• Entity-Relationship Data Model (ERM) is a
detailed, logical representation of the data for an
organization or for a business area.
– Expressed in terms of:
• Entities
• Attributes
• Relationships
• Entity-Relationship Diagram (ERD) is a
graphical representation of a Entity-Relationship
Model.
Entity / Relationship Diagrams
(ERD)

Entities Product

Attributes Price

Relationships between entities buys


Entity
• What is an Entity?
• Distinguishable “thing/object ” in the real
world.
• Has its own identity that distinguishes it
from other entities.
– Examples:
• Person: PROFESSOR, STUDENT
• Place: STORE, UNIVERSITY
• Object: MACHINE, BUILDING
• Event: SALE, REGISTRATION
• Concept: ACCOUNT, COURSE
Entity
(Entity Set Type vs. Entity Instances)
• Entity Set is a collection of entities that share common properties or
characteristics.

PROFESSO
STUDENT CLASS
R

• Entity Instance is a single occurrence of an entity type.

STUDENT

– Entities should always be placed in a rectangle!


Attributes
• Each Entity has a set of Attributes
• Attribute is a property or characteristic of an
entity that is of interest to the organization.
– Example:
• STUDENT: Student_ID, Student_Name,
Mobile_Number, etc
Relationships

• Relationships are associations between one or


more entity types.
• Are the “glue” that holds together components of
an E-R model.
• The degree of a relationship = is the number of
entity types that participate in a relationship.
– There are 3 common relationships:
1. Unary (degree one)
2. binary (degree two)
3. Ternary (degree three)
ER Diagram
Components of a ER Diagram
Different notations used for ER Diagram
Entity
Weak Entity

An entity that cannot be uniquely identified by its own attributes and


relies on the relationship with other entity is called weak entity.

The weak entity is represented by a double rectangle.


Attribute

An attribute describes the property of an entity.


An attribute is represented as Oval in an ER diagram.

There are four types of attributes:


1. Key attribute
2. Composite attribute
3. Multivalued attribute
4. Derived attribute
Attribute
1. Key attribute

A key attribute can uniquely identify an entity from an entity set.


Key attribute is represented by oval same as other attributes
however the text of key attribute is underlined.
Attribute
2. Composite attribute:

An attribute that is a combination of other attributes is known as


composite attribute.
Attribute
3. Multivalued attribute:

An attribute that can hold multiple values is known as multivalued


attribute.
It is represented with double ovals in an ER Diagram.
Attribute
4. Derived attribute:

A derived attribute is one whose value is dynamic and derived


from another attribute.
It is represented by dashed oval in an ER Diagram.
Attributes
Relationship

A relationship is represented by diamond shape in ER


diagram, it shows the relationship among entities.

There are four types of relationships:


1. One to One
2. One to Many
3. Many to One
4. Many to Many
Relationship

1. One to One Relationship

When a single instance of an entity is associated with a single instance


of another entity then it is called one to one relationship.
Relationship

2. One to Many Relationship

When a single instance of an entity is associated with more than one


instances of another entity then it is called one to many relationship.
Relationship

3. Many to One Relationship

When more than one instances of an entity is associated with a single


instance of another entity then it is called many to one relationship.
Relationship

4. Many to Many Relationship

When more than one instances of an entity is associated with more


than one instances of another entity then it is called many to many
relationship.
Cardinality Constraints
• Cardinality Constraints - the number of instances of one entity
that can or must be associated with each instance of another
entity.
• Minimum Cardinality
– If zero, then optional
– If one or more, then mandatory
• Maximum Cardinality
– The maximum number
Cardinality
Degree of Relationships
• Degree of a Relationship is the number of
entity types that participate in it
– Unary Relationship
– Binary Relationship
– Ternary Relationship
Degree of relationships

One entity
Entities of
related to
two different Entities of three
another of
types related different types
the same
to each other related to each
entity type
other
Unary relationships
Binary relationships
Ternary relationships

Note: a relationship can have attributes of its own


Keys in E/R Diagrams
• Every entity set must have a key

catego
name
ry

price

Product
catego
name
ry name

price
mak
Company
es
Product
stockp
rice

buys emp
loys
Person

addres name ssn


s
Generalization
Generalization uses bottom-up approach where two or more
lower level entities combine together to form a higher level new
entity.

The new generalized entity can further combine together with


lower level entity to create a further higher level generalized
entity.
Specialization
Specialization is a process in which an entity is divided into
sub-entities.
It as a reverse process of generalization
Specialization is a top-down process.
Aggregation
Aggregation is a process in which a single entity alone is
not able to make sense in a relationship so the
relationship of two entities acts as one entity.
online-pdf-no-copy.com

You might also like