0% found this document useful (0 votes)
9 views

Entity-Relationship Model

The document explains the Entity-Relationship Model, detailing entities, relationships, and their sets, along with mapping cardinalities and keys such as super keys, candidate keys, and primary keys. It also describes attributes, their types, and the concept of weak entity sets, as well as extended E-R features like generalization and specialization. Additionally, it provides examples related to a university database to illustrate these concepts.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Entity-Relationship Model

The document explains the Entity-Relationship Model, detailing entities, relationships, and their sets, along with mapping cardinalities and keys such as super keys, candidate keys, and primary keys. It also describes attributes, their types, and the concept of weak entity sets, as well as extended E-R features like generalization and specialization. Additionally, it provides examples related to a university database to illustrate these concepts.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Entity-Relationship Model

An entity is a “thing” or “object” in the real world that is distinguishable from all other objects.
For example, each person in a university is an entity. An entity has a set of properties, and
the values for some set of properties may uniquely identify an entity. For instance, a person may
have a person id property whose value uniquely identifies that person.
An entity set is a set of entities of the same type that share the same properties, or attributes.
The set of all people who are instructors at a given university, for example, can be defined as
the entity set instructor. Similarly, the entity set student might represent the set of all students in
the university.

A relationship is an association among several entities. For example, we can define a


relationship advisor that associates instructor Katz with student Shankar. This relationship
specifies that Katz is an advisor to student Shankar

.
A relationship set is a set of relationships of the same type. Formally, it is a mathematical
relation on n ≥ 2 (possibly nondistinct) entity sets. If E1 , E2 , . . . , En are entity sets, then a
relationship set R is a subset of
{(e 1 , e 2 , . . . , e n ) | e 1 ∈ E 1 , e 2 ∈ E 2 , . . . , e n ∈ E n }
where (e 1 , e 2 , . . . , e n ) is a relationship.

Consider the two entity sets instructor and student above Figure. We define the relationship
set advisor to denote the association between instructors and students. Figure 7.2 depicts
this association.
As another example, consider the two entity sets student and section. We can
define the relationship set takes to denote the association between a student and
the course sections in which that student is enrolled.

Mapping Cardinalities
Mapping cardinalities, or cardinality ratios, express the number of entities to
which another entity can be associated via a relationship set.

For a binary relationship set R between entity sets A and B, the mapping
cardinality must be one of the following:
One-to-one: An entity in A is associated with at most one entity in B, and an entity in B is
associated with at most one entity in A.
One-to-many: An entity in A is associated with any number (zero or more) of entities in B. An
entity in B, however, can be associated with at most one entity in A.

Many-to-one: An entity in A is associated with at most one entity in B. An entity in B, however,


can be associated with any number (zero or more) of entities in A.
Many-to-many: An entity in A is associated with any number (zero or more) of entities in B, and
an entity in B is associated with any number (zero or more) of entities in A.
Keys
Super key: A superkey is a set of one or more attributes that, taken collectively, allow us to
identify uniquely a tuple in the relation. Super key attributes can also contain NULL values.
(class, section, roll) => superkey
(class, section, roll, gender) => superkey
Candidate key: Such minimal superkeys are called candidate keys. Candidate key attributes
can also contain NULL values.
(class, section, roll) => candidate key
Primary key: A primary key, also called a primary keyword, is a column in a relational database
table that's distinctive for each record. It doesn't permit null values.
(id, class, section, name) id is the primary key.

Composite key: This type of primary key consists of two or more attributes, such as multiple
columns.
(class, section, roll) => composite key
Foreign key: A FOREIGN KEY is a field (or collection of fields) in one table, that refers to the
PRIMARY KEY in another table.

Attribute
In a database management system (DBMS), an attribute is a piece of data that describes an
entity. For example, in a customer database, the attributes might be name, address, and phone
number. In a product database, the attributes might be name, price, and date of manufacture.
Types of Attributes
Simple attributes: Simple attributes are those that cannot be further divided into sub-attributes.
For example, A student's roll number of a student or the employee identification number.

Composite attributes: Composite attributes are made up of two or more simple attributes. For
example, a person's address may be a composite attribute that is made up of the person's street
address, city, state, and zip code.

Single-Valued Attributes: Single-valued attributes can only have one value. For example, a
person's NID number or DOB is a single-valued attribute.

Multivalued Attributes: Multivalued attributes can have more than one value. For example, a
person may have multiple email addresses or phone numbers.
Derived attributes: Derived attributes are based on other attributes and are not stored directly
in the database.
For example: Consider a database of employees. Each employee has a date of birth, and we
might want to calculate their age. However, age is a derived attribute because it can be
determined from the date of birth.

Entity relationship diagram


Example: E-R diagram for the University Enterprise

In our university database, we have a constraint that each instructor must have exactly one
associated department. As a result, there is a double line in Figure 7.15 between instructor and
inst_dept, indicating the total participation of the instructor in inst_dept; that is, each instructor
must be associated with a department. Further, there is an arrow from inst_dept to department,
indicating that each instructor can have at most one associated department.

Similarly, entity sets course and student have double lines to relationship sets course_dept and
stud_dept respectively, as also entity set section to relationship set sec_time_slot. The first two
relationships, in turn, have an arrow pointing to the other relationship, department, while the
third relationship has an arrow pointing to time_slot.
Further, Figure 7.15 shows that the relationship set takes has a descriptive attribute grade, and
that each student has at most one advisor. The figure also shows that section is now a weak
entity set, with attributes sec_id, semester, and year forming the discriminator; sec_course is the
identifying relationship set relating the weak entity set section to the strong entity set course.

*** Representation of Weak Entity Sets Book(7.6.3)


As an illustration, consider the weak entity set section in the E-R diagram of Figure 7.15. This
entity set has the attributes: sec id, semester, and year. The primary key of the course entity set,
on which the section depends, is the course id. Thus, we represent the section by a schema
with the following attributes:
section (course id, sec id, semester, year)
The primary key consists of the primary key of the entity set course, along with the discriminator
of the section, which is sec id, semester, and year. We also create a foreign-key constraint on
the section schema, with the attribute course id referencing the primary key of the course
schema, and the integrity constraint “on delete cascade”. 7 Because of the “on delete cascade”
specification on the foreign key constraint, if a course entity is deleted, then so are all the
associated section entities.

Extended E-R Features


Generalization: It works on the principle of bottom-up approach. In Generalization lower-level
functions are combined to form higher-level function which is called entities. This process is
repeated further to make advanced-level entities. In the Generalization process properties are
drawn from particular entities and thus we can create generalized entities. We can summarize
the Generalization process as it combines subclasses to form a superclass.
Example of Generalization – Consider two entities Student and Patient. These two entities
will have some characteristics of their own. For example, Student entity will have Roll_No,
Name and Mob_No while patient will have PId, Name and Mob_No characteristics. Now in
this example Name and Mob_No of both Student and Patient can be combined as a Person to
form one higher-level entity and this process is called as Generalization Process.
Specialization : We can say that Specialization is opposite of Generalization. In
Specialization things are broken down into smaller things to simplify it further. We can also say
that in Specialization a particular entity gets divided into sub entities and it’s done on the basis
of it’s characteristics. Also in Specialization Inheritance takes place.

Example of Specialization – Consider an entity Account. This will have some attributes
consider them Acc_No and Balance. Account entity may have some other attributes like
Current_Acc and Savings_Acc. Now Current_Acc may have Acc_No, Balance and
Transactions while Savings_Acc may have Acc_No, Balance and Interest_Rate henceforth
we can say that specialized entities inherits characteristics of higher level entity.

*** Difference between Generalization and Specialization

Get More Information:


1. https://www.geeksforgeeks.org
2. https://www.youtube.com/watch?v=fHAfc7Hjq28&list=PLWPirh4EWFpGrpcMfZ6UcdI786
QdtSxV8

MMA
Adjunct Faculty, IIUC

You might also like