unit 2
unit 2
Object 13
10
11
12
1
3
4
5
6
7
8
9
Syllabus
Entity Relational model is a model for identifying entities to be represented in the database and
representation of how those entities are related.
Design Phases
Following are the six steps of database design process. The ER model is most relevant to first three
steps
• In this step, it is necessary to understand what data need to be stored in the database, what
applications must be built, what are all those operations that are frequently used by the system.
• The requirement analysis is an informal process and it requires proper communication with user
groups.
• There are several methods for organizing and presenting information gathered inthis step.
• This is a steps in which E-R Model i.e. Entity Relationship model is built.
• E-R model is a high level data model used in database design.
• The goal of this design is to create a simple description of data that matches with the requirements
of users.
• This is a step in which ER model in converted to relational database schema, sometimes called as
the logical schema in the relational data model.
• In this step, relational database schema is analyzed to identify the potential smise problems and to
refine it.
• The schema refinement can be done with the help of normalizing and restructuring the relations.
• The tasks that are performed in this step are building indexes on tables and clustering tables,
redesigning some parts of schema obtained from earlier design steps.
• Using design methodologies like UML (Unified Modeling Language) the design of the database
can be accomplished.
• The role of each entity in every process must be reflected in the application task.
• For each role, there must be the provision for accessing the some part of database and prohibition
of access to some other part of database.
• Thus some access rules must be enforced on the application(which is accessing the database) to
protect the security features.
ER Model
➢ The ER data model specifies enterprise schema that represents the overall logical structure
of a database.
➢ The E-R model is very useful in mapping the meanings and interactions of real-world
entities onto a conceptual schema.
1) Entity Sets
• Entity: An entity is an object that exists and is distinguishable from other objects. For example -
Student named "Poonam" is an entity and can be identified by her name. The entity can be concrete
or abstract. The concrete entity can be - Person, Book, Bank.The abstract entity can be like -
holiday, concept entity is represented as a box.
• Entity set: The entity set is a set of entities of the same types. For example - All students studying
in class X of the School. The entity set need not be disjoint. Each entity in entity set have the same
set of attributes and the set of attributes will distinguish it from other entity sets. No other entity set
will have exactly the same set of attributes.
2) Relationship Sets
➢ The relationship set is a collection of similar relationships. For example - Following Fig.
2.1.2 shows the relationship works for for the two entities Employee and Departments.
The association between entity sets is called as participation. That is, the entity sets E1, E2,..., En
participate in relationship set R.
The function that an entity plays in a relationship is called that entity's role.
3) Attributes
Attributes define the properties of a data object of entity. For example if student is an entity, his ID,
name, address, date of birth, class are its attributes. The attributes help in determining the unique
entity. Refer Fig. 2.1.3 for Student entity set with attributes - ID, name, address. Note that entity is
shown by rectangular box and attributes are shown in oval. The primary key is underlined.
Types of Attributes
1) Simple attributes are attributes that are drawn from the atomic value domains
1) Composite attributes: Attributes that consist of a hierarchy of attributes For example - Address
may consists of "Number", "Street" and "Suburb"→ Address = {59+ 'JM Road' + 'Shivaji Nagar'}
• There are some attributes that can be represented using a single value. For example
• Multivalued attributes: Attributes that have a set of values for each entity. It is represented by
concentric ovals
➢ For example Age can be derived from attribute DateOfBirth. In this situation, DateOfBirth
might be called Stored Attribute.
Mapping Cardinality
Mapping Cardinality
Mapping Cardinality represents the number of entities to which another entity can be associated via
a relationship set.
The mapping cardinalities are used in representing the binary relationship sets. Various types of
mapping cardinalities are -
1) One to One: An entity A is associated with at least one entity on B and an entity B is associated
with at one entity on A. This can be represented as,
4) 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.
ER Diagrams
ER Diagrams
An E-R diagram can express the overall logical structure of a database graphically.E-
R diagrams are used to model real-world objects like a person, a car, a company and
the relation between these real-world objects.
Features of ER model
i) E-R diagrams are used to represent E-R model in a database, which makes them
easy to be converted into relations (tables).
ii) E-R diagrams provide the purpose of real-world modeling of objects which makes
them intently useful.
iv) These diagrams are very easy to understand and easy to create even by a naive
user.
There are four types of relationships that are considered for key constraints.
i) One to one relation: When entity A is associated with at the most one entity B then
it shares one to one relation. For example - There is one project manager who
manages only one project.
ii) One to many :When entity A is associated with more than one entities at a time
then there is one to many relation. For example - One customer places order at a time.
iii) Many to one : When more than one entities are associated with only one entity
then there is is many to one relation. For example – Many student take a
ComputerSciCourse
iv) Many to many: When more than one entities are associated with more than one
entities. For example -Many teachers can teach many students.
Alternate representation can be
Ternary Relationship
The relationship in which three entities are involved is called ternary relationship. For
example -
• Ternary relationships are required when binary relationships are not sufficient to
• For example - Suppose, you have a database for a company that contains the
• Now consider the CUSTOMER entity, and that the customer buys products. If all
customers pay the same price for a product, regardless of supplier, then you have a
simple binary relationship between CUSTOMER and PRODUCT. For the
CUSTOMER/PRODUCT relationship, the intersection attribute is retail_price.
• Single ternary relation: Now consider a different scenario. Suppose the customer
buys products but the price depends not only on the product, but also on the supplier.
Suppose you needed a customerID, a productID, and a supplierID to identify a price.
Now you have an attribute that depends on three things and hence you have a
relationship between three entities (a ternary relationship) that will have the
intersection attribute, price.
• A weak entity is an entity that cannot be uniquely identified by its attributes alone.
The entity set which does not have sufficient attributes to form a primary key is
called as weak entity set.
The entity set that has primary key is called as strong entity set
entity sets.
• The key for a weak entity set is its own underlined attributes and the keys for the
supporting entity sets. For example - player-number and team-name is a key for
Players.