0% found this document useful (0 votes)
6 views22 pages

Se 2-3

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views22 pages

Se 2-3

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

UNIT II

ER DIAGRAM

- Abhilash Chakraborty
ENTITY- RELATIONSHIP BASIC CONCEPTS
The ER model defines the conceptual view of a database. It works
around real-world entities and the associations among them.

1. Entity

Represented by-

➢ An entity can be a real-world object that can be easily identifiable.


For example, in a school database, students, teachers, classes, and
courses offered can be considered as entities. All these entities have
some attributes or properties that give them their identity.
ENTITY- RELATIONSHIP BASIC CONCEPTS
➢ An entity set is a collection of similar types of entities. An entity
set may contain entities with attribute sharing similar values. For
example, a Students set may contain all the students of a school;
likewise a Teachers set may contain all the teachers of a school
from all faculties.

➢ Types of entity
▪ Strong entity
Represented by-

The Strong Entity is the one whose existence does not depend
on the existence of any other entity in a schema. It is denoted
by a single rectangle.
ENTITY- RELATIONSHIP BASIC CONCEPTS

▪ Weak entity
Represented by -

A weak entity is an entity that does not have sufficient attributes.


ENTITY- RELATIONSHIP BASIC CONCEPTS
2. Attributes
Represented by- Attribute

Entity

➢ Entities are represented by means of their properties,


called attributes. All attributes have values. For example, a student
entity may have name, class, and 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.
ENTITY- RELATIONSHIP BASIC CONCEPTS
Types of attributes
▪ Simple attribute − Simple attributes are atomic values, which cannot
be divided further. For example, a student's phone number is an
atomic value of 10 digits.
represented by -
Attribute

▪ 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.

Last_name
First_name

Student_name
ENTITY- RELATIONSHIP BASIC CONCEPTS
▪ Derived attribute − Derived attributes are the attributes that do not
exist in the physical database, but their values are derived from
other attributes present in the database. For example,
average_salary in a department should not be saved directly in the
database, instead it can be derived. For another example, age can be
derived from data_of_birth.

Age

D.O.B
ENTITY- RELATIONSHIP BASIC CONCEPTS
▪ Single-value attribute − Single-value attributes contain single value. For
example − Social_Security_Number.

98346---

Social_security_no

▪ Multi-value attribute − Multi-value attributes may contain more than


one values. For example, a person can have more than one phone
number, email_address, etc.

961------- 8787---

Adam_Phn_no
ENTITY- RELATIONSHIP BASIC CONCEPTS
3. Keys
➢ Key is an attribute or collection of attributes that uniquely
identifies an entity among entity set.
➢ For example, the roll_number of a student makes him/her
identifiable among students.

▪ Why we need a Key?


▪ Keys help you to identify any row of data in a table. In a real-world
application, a table could contain thousands of records. Moreover,
the records could be duplicated. Keys ensure that you can uniquely
identify a table record despite these challenges.
▪ Allows you to establish a relationship between tables and identify
the relation between tables
▪ Help you to enforce identity and integrity in the relationship.
ENTITY- RELATIONSHIP BASIC CONCEPTS
➢ Types of keys –
➢ Super Key − A superkey is any set of attributes for which the values
are guaranteed to be unique for all possible set of tuples (row) in a
table at all time.

➢ Candidate Key − A minimal super key is called a candidate key.


A Candidate Key can be any column or a combination of columns
that can qualify as unique key in database. An entity set may have
more than one candidate key.

➢ Primary Key − A Primary Key is a column or a combination of


columns that uniquely identify a record. Only one Candidate
Key can be Primary Key.
ENTITY- RELATIONSHIP BASIC CONCEPTS
4. Relationship
➢ The association among entities is called a relationship. For example,
an employee works_at a department, a student enrolls in a course.
Here, Works_at and Enrolls are called relationships.

➢ Represented by –

➢ Example -

Relatio
Entity entity
n
ENTITY- RELATIONSHIP BASIC CONCEPTS
➢ Relationship Set
A set of relationships of similar type is called a relationship set. Like
entities, a relationship too can have attributes. These attributes are
called descriptive attributes.
➢ Degree of relationship
▪ Degree of relationship is the number of entity sets that are
participated (associated) in that relationship. That is, the number of
entity sets that are connected through the relationship in question is
called the degree of relationship.
▪ Based on the degree, the relationships may be identified as unary
(degree 1), binary (degree 2), ternary (degree 3) and so on.
▪ Example of binary relationship

Relatio
Entity entity
n
ENTITY- RELATIONSHIP BASIC CONCEPTS
5. Mapping Cardinalities
Cardinality defines the number of entities in one entity set, which can
be associated with 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.
ENTITY- RELATIONSHIP BASIC CONCEPTS

▪ One-to-many − One entity from entity set A can be associated with


more than one entities of entity set B however an entity from entity
set B, can be associated with at most one entity.
ENTITY- RELATIONSHIP BASIC CONCEPTS

▪ Many-to-one − More than one entities from entity set A can be


associated with at most one entity of entity set B, however an entity
from entity set B can be associated with more than one entity from
entity set A.
ENTITY- RELATIONSHIP BASIC CONCEPTS

▪ Many-to-many − One entity from A can be associated with more


than one entity from B and vice versa.
ENTITY- RELATIONSHIP BASIC CONCEPTS
▪ Participation Constraints
▪ Total Participation − Each entity is involved in the relationship. Total
participation is represented by double lines.
▪ Partial participation − Not all entities are involved in the relationship.
Partial participation is represented by single lines.
ENTITY- RELATIONSHIP BASIC CONCEPTS
▪ Participation Constraints contd.
▪ Example –
ENTITY- RELATIONSHIP BASIC CONCEPTS
▪ Participation Constraints contd.
▪ Example –

Total Participation-
Double line between the entity set “Student” and relationship set
“Enrolled in” signifies total participation. It specifies that each
student must be enrolled in at least one course.

Partial Participation-
Single line between the entity set “Course” and relationship set
“Enrolled in” signifies partial participation. It specifies that there
might exist some courses for which no enrollments are made.
EXAMPLES-
EXAMPLES-
EXAMPLES-

You might also like