Unit -2.1
Unit -2.1
Data Modeling Using the Entity-Relationship (ER) Model: Using High- Level Conceptual
Data Models for Database Design - An Example Database Application - Entity Types, Entity Sets,
Attributes, and Keys - Relationship Types, Relationship Sets, Roles, and Structural Constraints -
Weak Entity Types.
Using High- Level Conceptual Data Models for
Database Design
The following Figure shows a simplified description of the database design process.
Step 1: Requirements collection and analysis: During this first step, the database
designers interview prospective database users to understand and document their data
requirements.
The result of this step is a concisely written set of user’s requirements. These
requirements should be specified in as detailed and complete a form as possible.
In parallel with specifying the data requirements, it is useful to specify the known
functional requirements of the application. These consist of the user defined
operations (or transactions) that will be applied to the database, including both
retrievals and updates.
Step 2: Conceptual design:Once all the requirements have been collected and
analyzed, the next step is to create a conceptual schema for the database, using a high-
level conceptual data model. This step is called conceptual design.
Create a conceptual schema for the database, using a high-level conceptual data
model. The conceptual schema is a concise description of the data requirements of the
users and includes detailed descriptions of entity types, relationship types, and
constraints.
Step 4: Physical Design: During which the internal storage structures, file
organizations, indexes, access paths, and physical design parameters for the database
files are specified.
In parallel with these activities, application programs are designed and implemented
as database transactions corresponding to the high-level transaction specifications.
ER Model Concepts
The main components and its symbols in ER Diagramsis as follows:
o Rectangles: This Entity Relationship Diagram symbol represents entity types.
o Ellipses: Symbol represent attributes.
o Diamonds: This symbol represents relationship types.
o Lines: It links attributes to entity types and entity types with other relationship
types.
o Primary key: attributes are underlined.
o Double Ellipses: Represent multi-valued attributes.
o The employee entity e1 has four attributes: Name, Address, Age, and
HomePhone; their values are "John Smith," "2311 Kirby, Houston, Texas
77001," "55," and "713-749-2630," respectively.
o The company entity c1 has three attributes: Name, Headquarters, and
President; their values are "Sunco Oil," "Houston," and "John Smith,"
respectively.
o Given below is another example of ER:
Types of Attributes in ER model:
o 1. Simple attributes:
o Each entity has a single atomic value for the attribute. Attributes that are not
divisible are called simple or atomic attributes.
o 2. Key Attribute:
o The key attribute is used to represent the main characteristics of an entity. It
represents a primary key. The key attribute is represented by an ellipse with
the text underlined.
o 3. Composite attributes:
o The attribute may be composed of several components. Component attributes
can be divided into smaller subparts, which represent more basic attributes
with independent meaning.
o The composite attribute is represented by an ellipse, and those ellipses are
connected with an ellipse.
o For example, 1:
Name (FirstName, MiddleName, LastName).
o For example, 2:
Address (Apt#, House#, Street, City, State, ZipCode, Country).
o 3. Single-valued attributes:
o Most attributes have a single value for a particular entity; such attributes are
called single-valued.
o 4. Multi-valued attributes:
o An entity may have multiple values for that attribute.
o The double oval is used to represent multivalued attribute.
o Example 1 : PreviousDegrees of a STUDENT, Denote by {PreviousDegrees}.
o Example 2: a student can have more than one phone number.
o 5. Stored vs. Derived attributes:
o A derived attribute is one whose value can be calculated from the values of
other attributes. Those other attributes are called stored attributes.
o Example, Age can be calculated from Birth_date.
o The age attribute is hence called derived attribute and is said to be derivable
from the Birth_date attribute, which is called a stored attribute.
o 6. Complex attribute:
o The complex attribute in DBMS involves both multivalued and composite
attributes.
o For example, someone might have more than one house, and each house might
have more than one phone. The phone is then considered a complex attribute.
o 7. NULL values:
o (a) Unknown value.
o (b) Unavailable or withheld.
o (c) Not applicable.
o (a) Unknown value. A person’s date of birth is not known, so it is represented
by NULL in the database.
o (b) Unavailable or withheld value. A person has a home phone but does not
want it to be listed, so it is withheld and represented as NULL in the database.
o (c) Not applicable attribute. An attribute LastCollegeDegree would be
NULL for a person who has no college degrees because it does not apply to
that person.
o Example:
Entity Types and Entity Sets
Entity Types:
o Entities with the same basic attributes are grouped or typed into an entity type.
or
o An entity type defines a collection of entities that have the same attributes.
o Each entity type in the database is described by its name and attributes.
o For example, the entity type EMPLOYEE and PROJECT.
Entity Sets:
o The collection of entities of a particular entity type in the database at any point
in time is called an entity set; the entity set is usually referred to using the
same name as the entity type.
o For example, EMPLOYEE refers to both a type of entity as well as current set
of all employee entities in the database.
o An entity type describes the schema or intension for a set of entities that share
the same structure.
o The collection of entities of a particular entity type is grouped into an entity
set, which is also called the extension of the entity type.
Attributesand Keys
An important constraint on the entities of an entity type is the key or uniqueness
constraint on attributes.
An attribute of an entity type for which each entity must have a unique value is
called a key attribute of the entity type. or
An entity type has one or more attributes whose values are distinct for each
individual entity in the entity set. Such attribute is called a key attribute
(composite key), and its value can be used to identify each entity uniquely.
Relationship:
o A relationship relates two or more distinct entities with a specific meaning.
Relationship type:
o Relationship Type can be defined the association between two entities.
o In a school database, a student enroll a course. Here enroll is a relationship.
Relationship Set:
o A relationship set is a set of relationships of same type.
o Relationship Set can be defined a set of similar type relationship. It is
represented by a diamond and connecting the entities by line.
o In a school database, there is a relationship between student set and course set.
Degree of a Relationship Set:
o The number of entity sets that participate in a relationship set is termed as the
degree of that relationship set. Thus,
o One-to-many relationship:
o An entity set A is associated with any number of entities in B with a
possibility of zero and an entity in B is associated with at most one entity in A.
o Many-to-one relationship:
o An entity set A is associated with at most one entity in B and an entity set in B
can be associated with any number of entities in A with a possibility of zero.
o Many-to-many relationship
o An entity set A is associated with any number of entities in B with a
possibility of zero and an entity in B is associated with any number of entities
in A with a possibility of zero.
2. Participation Constraints:
Participate constraints are two types as mentioned below −
o Total participation
o Partial Participation
The participation constraints are explained in the diagram below −
Here, the customer to Loan is partial participation and the loan to the customer is total
participation.
o Total participation:
o The participation of an entity set E in a relationship set R is said to be total if
every entity in E Participates in at least one relationship in R.
o For Example − Participation of loan in the relationship borrower is total
participation.
o Partial Participation:
o If only some of the entities in E participate in relationship R, then the
participation of E in R is said to be partial participation.
o For example − Participation of customers in the relationship borrower is
partial participation.
Weak Entity Types
Primary key Strong entity has Weak entity does not have
primary key. any primary key. But, it has a
partial discriminator key.
Key attribute Strong entity has a key Weak entity does not have
attribute. any key attribute.
Participation Strong entity can either Weak entity always have total
have no participation or participation.
total participation.