Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
1. Basic Concepts
2. Design Issues
3. Mapping Constraints
4. Keys
5. Entity-Relationship Diagram
6. Weak Entity Sets
7. Extended E-R Features
Entity set:
The entity is thing / object in the real world containing set of properties and the values to those
properties. The values of the properties uniquely identify the entity uniquely. The entity may be concrete
such as person or it may be abstract like loan, loan, and intelligence etc.
The entities of the same type and properties form the entity sets.
Ex: the entity set customer contains the all the tuple of the same type.
The attributes are the descriptive properties of the entities. The domain specifies the range of
allowed values that the entity set can have.
Ex: the age attribute can take values b/w 1 to 105
The name attribute can take any string.
The various types of attributes used in the E-R model are as follows.
The simple attributes are those that is not having the sub-pats.
Ex: age, sex, salary
The composite attributes are those that is formed by combining two of more.
Ex: the name attribute composed of first-name, middle-name, last-name
the address attribute is composed of street, door no etc.
The single valued attributes are those consisting of single value for an entities in the entity set.
Ex: the employee number is constant for the employee.
The multi valued attributes are those which can take the range of values.
Ex: the salary of employee depends on experience.
The age of employee depends on time
• Null
This value is used when the attribute of an entity does not have value or undefined/unknown.
Ex: the value of residence phone of an employee is NULL at the time of joining.
• Derived
The value of this type of attributes is derived from other attributes of the entity. It depends on the
values of other entities.
Ex: consider assets of an person it terms of Rs, it depends on the salary, ancestral property, bank
balance, shares etc.
Relationship set:
Relationship set is an association among existing entities. Relationship set is set of relations of the
same type.
Ex: consider a customer table and assets. We can define a relationship owner b/w these two as
below.
Customer:
Assets:
Mathematically the relationship set consists of entities N > = 2. If E1, E2, …. En are entity sets,
then a relationship set R is subset of
The number of entity set participate in the relationship set is called as degree of the relationship
set. In the above relation the entities that are present are customer and assets. Therefore the degree of the
relationship set is two / binary.
Mapping Constraints:
In E-R schema we may define certain constraints that the database must satisfy. The most
important types of constraints are mapping cardinalities & existence dependencies.
Mapping Cardinalities:
It specifies the number of entities to which another entity can be associated via a relationship set.
Consider a binary relationship set R b/w entities A and B the mapping cardinalities one of the following
• One to one
An entity in A is associated with at most one entity of B and Vice-Versa.
Ex: consider person and passport. Relationship is possessed.
• One to many
An entity of A can have any number of association with entities in B. but the entities of B can have at
most only one association with entity in A.
Ex: customer and account. Relationship is depositor.
• Many to one:
An entity of A can have only one association with B. but entities of B can have any number of
association with entities of A.
Ex: customer and loan . relationship is borrower.
• Many to Many
An entity in A can have any number of association with entities in B and vice- versa.
Ex: customer and sales man. Relationship is sells.
Existence dependencies:
Consider two entities X and Y. if existence of Y is depends on existence of X the we say that
entity Y is dependent on X. X is called a dominant entity and Y is subordinate entity.
Ex:
Consider two entities customer & accounts. The account is dependent on customer. If we delete
the customer entity the corresponding entity in accounts is also deleted.
Keys:
The entities in an entity set are identified uniquely by the key values. The are basically two types
of keys Primary Key and Foreign Key.
Primary Key is key formed by the set of attributes by which the entities in the entity set are
identified uniquely.
Foreign Key is a key in the table used to reference the attribute values of the other table. The
Foreign Key is Primary Key in the referencing entity set.
Entity-Relationship Diagram:
The database can be pictorially represented by the E-R diagram. It is relatively simple and easy to
write. Therefore it is adopted in the most database system. The elements of E-R diagram are as follows.
• Rectangles represents the entity sets
• Ellipses represents the attributes
• Diamonds represents the relationship sets
• Lines which links the attributes to entity set and entities to relationship set.
• Double Ellipses represents the multi-valued attributes.
• Dashed Ellipses represents the derived attributes.
• Double lines represent the total participation of entities in a relationship set.
The attributes of the entity set which are primary key is underlined.
Consider the entity set customer and loan. The primary keys are social-security number and
loan-number. The relationship b/w these two is One-to-One. Pictorially it is represented as follows
Social Customer
-security street Loan-
number amount
Customer Customer
name city
The primary key of weak entity set is formed by the primary key of the strong entity set on which
the weak entity set existence is depends plus the weak entity set discriminator. Hence the primary key of
the payment is { loan-number, payment-number }
The weak entity set in the E-R diagram is indicated by the doubly outlined box with corresponding
identifying relationship set loan-payment.
Payment-date
Payment-No Payment-
Loan- ---------- amount
Amount
number
Loan Loan-
payment payment
Specialization:
The process of sub-grouping of entities within the entity set is called as specialization.
The some entities in the entity set may distinct in some form from other entity set. The subset of
entities in the entity set does not share the some distinct attributes with other entities. The E-R diagram
provides a grouping mechanism to specify this.
Ex:
Consider the entity set account with the attributes account-number and amount. The account can
be classified further into
• Savings-account
• Checking-account
These account types are derived from base entity account hence it contains all the properties
of account with additional attributes. The Savings-account contains additional attributes
interest-rate. The Checking-account contains additional attribute overdraft-amount. The
specialization of account allows us to distinguish among accounts based on the type of account.
Account-No Balance
Account
IS
A Overdraft-
Interest-rate amount
Savings-account Checking-account
Generalization:
Specialization starts at the single entity set. It identifies the groups among the entity set. These
lower level entity set have attributes and participate in the relationship. And the do not apply to all entities
in the higher level.
Generalization proceeds from the recognition of the sameness among the various entity sets.
Based on these commonalties generalization synthesizes these sets into a single higher-level entity set.
Attribute Inheritance:
The property of higher-level entity set and the lower-level entity set is the attribute inheritance.
The lower-level entity set inherits the attributes of the higher-level entity set.
Ex: the savings-account and the checking-account inherit the attribute balance of entity account. The lower-
level entity set also participates in the relationship in which higher-level entity set participates.
Aggregation:
It is an abstraction through which relationships are treated as higher-level entities.
Ex:
Social-
security
Customer-street Loan-number amount
Customer-name Customer-city
customer loan
borrow
er
Loan-
office
r
employee
e-social-security Telehone-no
Emp-name
The aggregation solves this problem. We consider the relationship set borrower and entity set
customer and loan as a higher-level entity set borrower. It is mentioned in the dashed rectangle.
Design of E-R Database Schema:
While designing the database schema using E-R model the following decisions are to be made.
Design Phases:
Brief description of design phases as followes.
The initial requirements are collected by interviewing the user who uses the database. The analysis
is done by the designer on the collected data. If he needs the more information he consults the user of the
system.
Data Model:
The designer chooses the data model. He translates the above specifications into the appropriate
database schema using the concepts of that data model. The designer reviews the schema that all data
requirements are satisfied and no conflict in the schema.
The fully developed schema specifies the functional requirements. This specifies the transactions
can be performed on the data.