0% found this document useful (0 votes)
2 views

unit 2

Uploaded by

shanthi
Copyright
© © All Rights Reserved
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

unit 2

Uploaded by

shanthi
Copyright
© © All Rights Reserved
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 13

Object

Object 13
10
11
12
1
3
4
5
6
7
8
9

Introduction to Entity Relationship Model


Unit: II: Database Design

Syllabus

Entity-Relationship model - E-R Diagrams - Enhanced-ER Model - ER-to-Relational Mapping -


Functional Dependencies Non-loss Decomposition - First, Second, Third Normal Forms,
Dependency Preservation - Boyce/Codd Normal Form Multi-valued Dependencies and Fourth
Object 2

Normal Form - Join Dependencies and Fifth Normal Form.

Part I: Entity Relationship Model

Introduction to Entity Relationship Model

Entity Relational model is a model for identifying entities to be represented in the database and
representation of how those entities are related.

Let us first understand the design process of database design.

Design Phases

Following are the six steps of database design process. The ER model is most relevant to first three
steps

Step 1: Requirement analysis:

• 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.

• Some automated tools can also be used for this purpose.

Step 2: Conceptual database design:

• 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.

Step 3: Logical database design:

• 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.

Step 4: Schema refinement:

• 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.

Step 5: Physical database design:

• In this step, the design of database is refined further.

• 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.

Step 6: Application and security design:

• 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.

➢ The ER model consists of three basic concepts -

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

➢ Relationship is an association among two or more entities.

➢ 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 and Composite Attributes:

1) Simple attributes are attributes that are drawn from the atomic value domains

For example - Name = {Parth}; Age = {23}

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'}

2) Single valued and multivalued:

• There are some attributes that can be represented using a single value. For example

- StudentID attribute for a Student is specific only one studentID.

• Multivalued attributes: Attributes that have a set of values for each entity. It is represented by
concentric ovals

For example - Degrees of a person: BSc', 'MTech', 'PhD'


➢ Derived attributes are the attributes that contain values that are calculated from other
attributes. To represent derived attribute there is dotted ellipse inside the solid ellipse.

➢ 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,

2) 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.
3) Many to One: An entity in A is associated with at most one entity in B. An entity in B, however,
can be associated with any number of entities in A.

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.

iii) E-R diagrams require no technical knowledge and no hardware support.

iv) These diagrams are very easy to understand and easy to create even by a naive
user.

v) It gives a standard solution of visualizing the data logically.

Various Components used in ER Model are-


Mapping Cardinality Representation using ER Diagram

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

Alternate representation can be

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 -

Binary and Ternary Relationships

• Although binary relationships seem natural to most of us, in reality it is sometimes

necessary to connect three or more entities. If a relationship connects three entities, it


is called ternary or "3-ary."

• Ternary relationships are required when binary relationships are not sufficient to

accurately describe the semantics of an association among three entities.

• For example - Suppose, you have a database for a company that contains the

entities, PRODUCT, SUPPLIER, and CUSTOMER. The usual relationships might be


PRODUCT/ SUPPLIER where the company buys products from a supplier - a
normal binary relationship. The intersection attribute for PRODUCT/SUPPLIER is
wholesale_price

• 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.

Weak Entity Set

• 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.

• Strong Entity Set

The entity set that has primary key is called as strong entity set

Weak entity set because each player needs a team

Weak entity rules


• A weak entity set has one or more many-one relationships to other (supporting)

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.

Difference between Strong and Weak Entity Set

You might also like