Ch:2 Entity Relationship Model
Ch:2 Entity Relationship Model
6.1
Basic Concepts
A database can be modeled as:
a
relationships among
that share the same properties. Example: set of all customer, employees etc.
6.3
attributes. Example.
Domain:- For each attribute , there is a set of
6.4
Types of attributes
Attribute types:
Simple
Single-valued and
attributes.
Derived
attributes
6.5
subparts. e.g. id
Composite attribute:- cab be divided into
composite attribute address, its component attribute street can be further divided into street no, street name etc. figure
6.6
an employee entity.
6.7
Derived attributes
The value of Age attribute of the customer entity
6.8
exists but we do not have that information) or not known (we do not know whether or not the value actually exists).
6.9
entities e.g. we can define a relationship that associates customer with loan. (depositor)
Relationship Sets:- it is a set of relationships of
define the relationship set borrower to denote the association between customers and bank loans that the customer have.
6.10
loan-branch.
Participation:- Association between entity sets. i.e.
6.11
have attribute. E.g. depositor relationship set with entity sets customer and account. We can associate access-date attribute to that relationship to specify the most recent date on which a customer accessed an account.
Degree: no of entities participating in a
relationship set
Database System Concepts - 5th Edition, Oct 5, 2006 6.12 Silberschatz, Korth and Sudarshan
Constraints
Mapping cardinalities
Participation
6.13
involve more than two entity sets. The entity sets customer, loan, and branch may be linked by the ternary (degree three) relationship set .
6.14
most one entity in B, and entity in B is associated with at most one entity in A. Figure
One to Many: An entity in A is associated with
any number of entities in B. An entity in B however can be associated with at most one entity in A. Figure
Database System Concepts - 5th Edition, Oct 5, 2006 6.15 Silberschatz, Korth and Sudarshan
at most one entity in B. An entity in B, however can be associated with any number of entities in A. figure
Many to Many : An entity in A is associated with
any number of entities in B and an entity in B is associated with any number of entities in A. figure
6.16
Participation Constraints
Total Participation: The participation of an entity
set E in relationship set R is said to be total if every entity in E participate in at least one relationship in R.
Partial Participation : If only some entities in E
6.17
through the borrower relationship. So the participation of loan in relationship set borrower is total.
6.18
Keys
Super Key
Candidate Key Primary Key
Foreign Key
6.19
that is chosen by the database designer as the principal means of identifying entities within an entity set.
6.20
that points to the primary key of another table. The purpose of the foreign key is to ensure referential integrity of the data.
6.21
ERD
Entity Set :- Rectangles
Attribute:- Ellipse Relationship Set:- Diamond
6.22
6.23
One-To-Many Relationship
6.24
Many-To-One Relationships
6.25
One-to-One Example
6.26
6.27
6.28
6.29
Roles
6.30
6.31
6.32
form a primary key. Such an entity set is termed a weak entity set.
An entity set that has a primary key is termed a
6.33
payment.
Discriminator / Partial Key:- the discriminator of
6.35
6.36
6.37
Extended ER Features
Specialization
Generalization Attribute inheritance
Constraints on generalization
Aggregation
6.38
Specialization
Consider an entity set person , with attributes
following:
Customer Employee
attributes that includes all the attributes of entity set person + possibly additional attributes.
6.39
divide accounts into two categories , checking account and saving account.
Specialization of account :- checking account and
saving account.
Attributes of account entity are account no and
balance.
6.40
overdraft_amt
ISA concept
6.41
Specialization Example
6.42
Generalization
Bottom up manner
Multiple entity sets are synthesized into higher
(sub classes )
6.43
Generalization
Example
Account saving & checking For this , we have three tables:
int_rate
Checking_account with attributes account_no and
overdraft_amount.
6.44
Aggregation
It is an abstraction through which relationships
6.45
Aggregation
Example
The table for relationship set manages between
the aggregation of works-on and the entity set manager includes a column for each attribute in the primary keys of the entity set manager and the relationship set works-on.
Also include a column for any descriptive
attribute
6.46
Distinguished specialization
Synthesized - generalization If customer and employee neither have attributes
that person entity do not have nor participate in different relationships than those in which person entity participate , there would be no need to specialize the person entity set.
Generalization proceeds from the identification
EER
Disjoint Overlapping Partial Total Examples & Symbols
6.48
Attribute Inheritance
The attributes of higher level entity sets are said
of person.
A lower level entity set also inherits participation
in the relationship sets in which its higher level entity participates. Example
Single inheritance :- in a hierarchy, a given entity
set may be involved as a lower level entity set in only one ISA relationship.
Database System Concepts - 5th Edition, Oct 5, 2006 6.49 Silberschatz, Korth and Sudarshan
than one ISA relationship , then the entity set has multiple inheritance.
6.50
higher level entity set account having an attribute account_type. Only those entities that satisfy the condition account type=saving account OR account type=checking account are included.
user-defined:-
e.g. let us assume that , after 3 months of employment, bank employees are assigned to one of four work teams.
6.51 Silberschatz, Korth and Sudarshan
individual basis.
6.52
an entity can either be saving account or checking account ,but can not be both. example : employee work team. Certain manager can participate in more than one work team. A given employee may therefore appear in more than one of the team entity sets that are lower level entity sets of employees.
Overlapping:
6.53
not an entity in the higher-level entity set must belong to at least one of the lower-level entity sets within a generalization.
Total:
Each higher level entity must belong to lower level entity set.
some higher level entities may not belong to any lower level entity set.
Partial:-
6.54
6.55
be represented by a collection of tables. For each entity set and relationship set there is a unique table which is assigned the name of the corresponding entity set or relationship set. Each table has a number of columns (generally corresponding to attributes), which have unique names. Converting an E-R diagram to a table format is the basis for deriving a relational database design from an E-R diagram.
6.56
.,an.
We represent this entity by a table called E with n
6.57
6.58
attributes loan_no and amount can be represented in table called loan with two columns.
We can add a new entity to the database by
6.59
6.60
columns: three attributes of payment entity set + Primary Key (loan no) of loan entity set.
6.61
the primary keys of the two participating entity sets, and any descriptive attributes of the relationship set. E.g.: table for relationship set borrower
6.62
Separate table will be created only for many- to-many relationship set.
6.63
payment_no + loan_no and the primary key of the loan entity set is loan_no.
Now the loan-payment table would have two
6.64
columns.
Every (loan_no, payment_no) combination in
loan-payment would also be present in the payment table, and vice versa.
So the loan-payment table is redundant. In general, the table for the relationship set
linking a weak entity set to its corresponding strong entity set is redundant and does not need to be present in a tabular representation of ER diagram.
Database System Concepts - 5th Edition, Oct 5, 2006 6.65 Silberschatz, Korth and Sudarshan
Combination of Tables
Figure
Entities Account &Branch Relationship set Account-Brach
6.66
6.67
Composite Attribute
We handle composite attribute by creating a
attribute itself.
Example
6.68
Multivalued Attribute
New tables are created for these attributes.
E.g. for the multivalued attribute , phone_no, we
create a table phone_no with columns ph_no referring to the phone number attribute of the employee entity set and employee_id, representing the primary key of the employee set employee.
6.69