Professional Documents
Culture Documents
ERD
ERD
ERD
6.1
Basic Concepts
A database can be modeled as:
a
collection of entities,
that share the same properties. Example: set of all customer, employees etc.
6.3
attributes. Example.
Domain / Value Set:- For each attribute , there is
Types of attributes
Attribute types:
Simple and
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
can be derived from attribute date-of-birth. date-of Date-of-birth :- base attribute / stored attribute Date-of:-
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
taken more than one loan. Another Example: An employee can supervise another employee. Descriptive attribute:- a relationship may also 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
6.12
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 Link : Line (links attributes to entity sets and
6.22
6.23
One-ToOne-To-Many Relationship
6.24
Many-ToMany-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
the identifying entity set. The identifying entity set is said to be own the weak entity set that it identifies. Identifying Relationship Loan identifying entity set for weak entity set payment. Discriminator / Partial Key:- the discriminator of the weak entity set payment is the attribute payment_no.
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 Each of these person type is described by a set of
attributes that includes all the attributes of entity set person + possibly additional attributes.
6.39
within an entity set is called specialization. Up-to-Down Another example :- suppose bank wishes to 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
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.45
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.46 Silberschatz, Korth and Sudarshan
than one ISA relationship , then the entity set has multiple inheritance.
6.47
account having an attribute account_type. Only those entities that satisfy the condition account type=saving account OR account type=checking account are included. assume that , after 3 months of employment, bank employees are assigned to one of four work teams.
6.48 Silberschatz, Korth and Sudarshan
Higher level entity set employee Lower level entity sets: four work teams The user in-charge makes the team assignment on
individual basis.
6.49
to more than one lower-level entity set within a single generalization. Disjoint: an entity can either be saving account or checking account ,but can not be both. Overlapping: 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.
6.50
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
higher level entities may not belong to any lower level entity set.
6.51
Aggregation
It is an abstraction through which relationships
6.52
6.53
Reduction of an E-R Schema to Tables E A database which conforms to an E-R diagram can
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.54
.,an.
We represent this entity by a table called E with n
6.55
6.56
Four attributes: id, name, street, city So table contains four columns. Another example:-the loan entity set with two
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.57
6.58
columns: three attributes of payment entity set + Primary Key (loan no) of loan entity set.
6.59
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.60
Separate table will be created only for many- to-many relationship set.
6.61
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.62
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.63 Silberschatz, Korth and Sudarshan
Combination of Tables
Figure Entities Account &Branch Relationship set Account-Brach Participation of account entity set is total Participation of branch entity set is partial Account can not exist without branch.
6.64
Relationship set : account-branch many to one So we can combine the table account-branch
6.65
Composite Attribute
We handle composite attribute by creating a
attribute itself.
Example
6.66
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.67
Generalization
Example Account saving & checking For this , we have three tables: Account with attributes account_no and balance Saving_account with attribute account_no and
int_rate
Checking_account with attributes account_no and
overdraft_amount.
6.68
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.69