Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
https://forms.gle/wtmtdYHdWnftcd5r6
ER Model (Conceptual View of a Database)
• ER Model: It works around real world entities and the associations among them.
• Entity (a real world object)
• For example, in a school database, students, teachers, classes, and courses
offered can be considered as entities.
• All the entities have some attributes or properties that give them their identity.
• An entity set is a collection of similar types of entities.
• 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 or value set 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.
Types of attributes
In this example the primary key field in the Customers table, Customer ID, is designed to contain unique
values. The foreign key field in the Orders table, Customer ID, is designed to allow multiple instances of
the same value.
Mapping Cardinalities contd..
• Many-to-One: (vice versa to One-to-Many)
• 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.
• It depends on which side of the relationship the entity is present on.
For example, if one department can employ for several employees then,
department to employee is a one to many relationship (1 department
employs many employees), while employee to department relationship is
many to one (many employees work in one department).
Mapping Cardinalities contd..
• Many-to-Many
• One entity from A can be associated with more than one entity from B and
vice versa.
• Many-to-Many relationship can be seen between project and employee. An
employee works on many projects and at the same time, a project has several
employees.
Participation Constraints
• Total Participation: the participation of an entity set E in a relationship
set R is said to be total if every entity in E participates in atleat one
relationship in R.
• For example, participation of Loan in the relationship Borrower is total. That
means, each entry in loan is associated with any one or more entries in
customer table.
• Partial Participation: Total Participation: the participation of an entity
set E in a relationship set R is said to be partial if only some entities in
E participates in relationship R.
• For example, participation of Customer in the relationship Borrower is partial.
That means, every customer has not taken loan.
Weak Entity Set
• An entity set that does not have a primary key is referred to asa weak entity set.
• The existence of a weak entity set depends on the existence of a identifying entity set
• It must relate to the identifying entity set via a total, one-to-many relationship set from the
identifying to the weak entity set.
• The discriminator(or partial key)of a weak entity set is the set of attributes that
distinguishes among all the entities of a weak entity set.
• The primary key of a weak entity set is formed by the primary key of the strong entity set on
which the weak entity set is existence dependent, plus the weak entity set’s discriminator.
• Example: A company may store the information of dependants (Parents, Children, Spouse)
of an Employee. But the dependents don’t have existence without the employee. So
Dependent will be weak entity type and Employee will be Identifying Entity type for
Dependant.
Example - Weak Entity Set
Primary Key
Item_No Name Unit Cost
MX300 Mountain Bike 75,000
Item Table
TR425 Tandem Bike 80,000
FK FK
Item_No Component_No Quantity
Component
MX300 HX100 1 Table
MX300 TX100 1
MX300 WX240 2
TX100 BR450 2
TX100 DX500 1
Unary M:N relationship
ITEM and COMPONENT Relations with sample data
Exercise