0% found this document useful (0 votes)
45 views15 pages

Data Base Management System 2

Dbms

Uploaded by

yathiy958
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views15 pages

Data Base Management System 2

Dbms

Uploaded by

yathiy958
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Database Management System

Data Base Management System


UNIT-1: Introduction
Chapter 2: E_R Model
Entity-Relationship Model
The E-R model is very useful in mapping the meanings and interactions of real-world
enterprises onto a conceptual schema. The E-R data model employs three basic notions: entity
sets, relationship sets and attributes.
Entity sets: An entity is a thing or object in the real world that is distinguishable from all
other objects. For example: specific person, company, event, plant.
An entity has a set of properties and the values for some set of properties may uniquely
identify an entity. For instance, a person may have a person_id property whose value
uniquely identifies that person.
An entity set is a set of entities of the same type that share the same properties or
attributes.
Figure 1 represents the entity sets of Instructor and Student.

Figure 1: Entity sets of Instructor and Student


Relationship Sets: A relationship is an association among several entities
Example: 44553 (Peltier) advisor 22222 (Einstein)
student entity relationship set instructor entity
A relationship set is a mathematical relation among n ≥ 2 entities, each taken from entity sets
{(e1, e2, … en) | e1 ∈ E1, e2 ∈ E2, …, en ∈ En} where (e1, e2, …, en) is a relationship
Example: (44553,22222) ∈ advisor

Srikanth T N, Dept. Of BCA, SRS First Grade College Page 1


Database Management System

The association between entity sets is referred to as participation that is the entity sets
E1,E2,…En participate in relationship set R. A relationship instance in an E-R schema
represents an association between the named entities in the real world enterprise that is being
modeled.
Consider a relationship set depositor with entity sets customer and account. We could
associate the attribute access_date to that relationship to specify the most recent date on
which a customer accessed an account. A relationship of this type of attributes is called
descriptive attributes.

Figure 2: Access_date as attribute of the depositor relationship set


Attributes: There is a set of permitted values called domain or value set of that attribute. An
attribute can be characterized by the following attribute types.
 Simple and composite attributes: Simple attributes are attributes that they have not been
divided into subparts. Composite attributes can be divided into subparts. Example: an
attribute name could be structured as a composite attribute consisting of first_name,
middle_initial and last_name.

Figure 3: Composite attributes customer_name and customer_address

Srikanth T N, Dept. Of BCA, SRS First Grade College Page 2


Database Management System

 Single-valued and multivalued attributes: For instance where an attribute has only one
value for a specific entity. Such attributes are said to be single valued. Example: The
loan_number attribute for a specific loan entity refers to only one loan number.
There may be instances where an attribute has a set of values for a specific entity. This type
of attribute is said to be multivalued. Example: Consider an employee entity set with the
attribute phone_number. An employee may have zero, one or several phone numbers and
different employees may have different numbers of phones.
 Derived attributes: The value for this type of attribute can be derived from the values of
other related attributes or entities. Example: The customer entity set has an attribute age that
indicates the customer’s age. If the customer entity set also has an attribute date_of_birth, we
can calculate age from date_of_birth and the current date. Age-Derived attribute,
date_of_birth-Base attribute or stored attribute.
Constraints
 Mapping Cardinalities: Mapping Cardinalities or Cardinality ratio express the number
of entities to which another entity can be associated via a relationship set.
For a binary relationship set R between entity sets A and B, the mapping cardinality must
be:
 One to one: An entity in A is associated with at most one entity in B and an entity in B is
associated with at most one entity in A.
 One-to-many: An entity in A is associated with any number (zero or more) of entities in
B. An entity in B, however can be associated with at most one entity in A.
 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 (zero or more) of entities in A.
 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.

Srikanth T N, Dept. Of BCA, SRS First Grade College Page 3


Database Management System

Figure 4: Mapping Cardinalities a) One-to-one b) One-to-many

Figure 5: Mapping Cardinalities a) Many-to-one b)Many-to-many


 Keys: The values of the attribute values of an entity must be such that they can uniquely
identify the entity. A key allows us to identify a set of attributes that suffice to distinguish
entities from each other.
 Entity Sets:
A super key of an entity set is a set of one or more attributes that taken collectively,
allows us to identify uniquely an entity in the entity set.
If K is a super key, then so is any superset of K. The super keys for which no proper
subset is a super key, Such minimal super keys are called candidate keys.
Example: course_id is candidate key of course.
The term primary key is used to denote a candidate key that is chosen by the database
designer as the principal means of identifying entities within an entity set.

Srikanth T N, Dept. Of BCA, SRS First Grade College Page 4


Database Management System

A key (primary, candidate and super) is a property of the entity set rather than of the
individual entities.
 Relationship Sets:
Let R be a relationship set involving entity sets E1,E2,…,En. Let primary key(Ei) denote
the set of attributes that forms the primary key for entity set Ei. The composition of the
primary key for a relationship set depends on the set of attributes associated with the
relationship set R.
If the relationship set R has no attributes associated with it, then the set of attributes
primarykey(E1)Uprimarykey(E2)U…..Uprimarykey(En)
describes an individual relationship in set R.
If the relationship set R has attributes a1,a2,….,am associated with it, then the set of
attributes.
primarykey(E1)Uprimarykey(E2)U…..Uprimarykey(En)U{a1,a2,…..,am}
describes an individual relationship in set R.
In both of the above cases, the set of attributes
primarykey(E1)Uprimarykey(E2)U…..Uprimarykey(En)
forms a superkey for the relationship set.
 Participation Constraints:
The participation of an entity set E in a relationship set R said to be total if every entity in
E participates in at least one relationship in R. If only some entities in E participate in
relationships in R, the participation of entity set E in relationship R is said to be partial.
Example: every loan entity to be related to at least one customer through the borrower
relationship. Therefore the participation of loan in the relationship set borrower is total.

Extended E-R Features


Specialization:
Top-down design process designates sub groupings within an entity set that are distinctive
from other entities in the set. These sub groupings become lower-level entity sets that have
attributes or participate in relationships that do not apply to the higher-level entity set. As in
Figure 11, it is depicted by a triangle component labeled ISA (E.g., instructor “is a” person).
The process of designating sub groupings within an entity set is called specialization.
Attribute inheritance – a lower-level entity set inherits all the attributes and relationship
participation of the higher-level entity set to which it is linked.

Srikanth T N, Dept. Of BCA, SRS First Grade College Page 5


Database Management System

Figure 11: Specialization and Generalization.


Consider an entity set person, with attributes ID, name and address. A person may be
further classified as one of the following:
 employee
 student
Each of these person types is described by a set of attributes that includes all the attributes
of entity set person plus possibly additional attributes. For example, student entities may be
described further by an attribute tot_credits, whereas employee entities may be described
further by the attribute salary.
Generalization: A bottom-up design process – combine a number of entity sets that share the
same features into a higher-level entity set. Specialization and generalization are simple
inversions of each other; they are represented in an E-R diagram in the same way. The terms
specialization and generalization are used interchangeably.
Entity can have multiple specializations of an entity set based on different features. E.g.,
permanent_employee vs. temporary_employee, in addition to instructor vs. secretary. Each
particular employee would be a member of one of permanent_employee or
temporary_employee, and also a member of one of instructor, secretary. The ISA
relationship also referred to as superclass - subclass relationship.

Srikanth T N, Dept. Of BCA, SRS First Grade College Page 6


Database Management System

Completeness constraint -- specifies whether or 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: an entity must belong to one of the lower-level entity sets.
 partial: an entity need not belong to one of the lower-level entity sets.
Aggregation: Consider the ternary relationship proj_guide. Suppose we want to record
evaluations of a student by a guide on a project, that is, we want to record evaluations for
(instructor, student and project) combinations.

Figure 12: E-R diagram with redundant relationship.


Relationship sets eval_for and proj_guide represent overlapping information. Every
eval_for relationship corresponds to a proj_guide relationship. However, some proj_guide
relationships may not correspond to any eval_for relationships. So we can’t discard the
proj_guide relationship.
Without introducing redundancy, the following Figure 13 represents:
 A student is guided by a particular instructor on a particular project.
 A student, instructor, project combination may have an associated evaluation.

Srikanth T N, Dept. Of BCA, SRS First Grade College Page 7


Database Management System

Figure 13: E-R diagram with aggregation.


Weak Entity Sets
An entity set that does not have a primary key is referred to as a weak entity set.
The discriminator (or partial key) of a weak entity set is the set of attributes that distinguishes
among all the entities of a weak entity set.
Consider the entity set section, which has the three attributes: sec_id, semester and year.
Section ids are sequential numbers, starting from 1, generated separately for each loan.
Although each section entity is distinct, sections for different course may share the same
section id. Thus, this entity set doesn’t have a primary key, it is a weak entity.

Figure 10: E-R diagram with a weak entity set.


We underline the discriminator of a weak entity set with a dashed line and also we put the
identifying relationship of a weak entity in a double diamond.

Srikanth T N, Dept. Of BCA, SRS First Grade College Page 8


Database Management System

Entity-Relationship Diagrams

Srikanth T N, Dept. Of BCA, SRS First Grade College Page 9


Database Management System

If a relationship set has also some attributes associated with it, then we link these
attributes to that relationship set. For example, in Figure 6 we have the date descriptive
attribute attached to the relationship set depositor to specify the date on which a instructor
advised that student.

Figure 6: E-R diagram with an attribute attached to a relationship set.


Figure 7 consists of the three entity sets instructor, project and student related through
the relationship set proj_guide.
Suppose a instructor can guide atmost one project for each student. This constraint
can be specified by an arrow pointing to project on the edge from proj_guide.

Figure 7: E-R diagram with a ternary relationship


Total participation (indicated by double line) represents every entity in the entity set
participates in at least one relationship in the relationship set. E.g., participation of section in
sec_course is total. Every section must have an associated course.
Figure 8 shows partial participation indicates some entities may not participate in any
relationship in the relationship set. Example: participation of instructor in advisor is partial

Srikanth T N, Dept. Of BCA, SRS First Grade College Page 10


Database Management System

Figure 8: Total participation of an entity set in a relationship set.


In E-R diagram, an edge between an entity set and a binary relationship set can have
an associated minimum and maximum cardinality shown in the form l…h, where l is the
minimum and h the maximum cardinality. A minimum value of 1 indicates total participation
of the entity set in the relationship set. A maximum value of 1 indicates that the entity
participates in at most one relationship, while a maximum value * indicates no limit. Note
that a label 1….* on an edge is equivalent to a double line.
Consider Figure 9, the edge between instructor and student has a cardinality constraint
of 1...1, meaning the minimum and the maximum cardinality are both 1. That is, each student
must have exactly one associated instructor. The limit 0…* on the edge from instructor to
advisor indicates that a instructor can have zero or more students. Thus, the relationship
advisor is one to many from instructor to student and further the participation of instructor in
advisor is total.

Figure 9: Cardinalities limits on relationship sets.


Design Phases:
 The initial phase of database design is to characterize fully the data needs of the
prospective database users. The database designer needs to interact extensively with domain
experts and users to carry out this task
 The designer chooses a data model by applying the concepts of the chosen data model,
translates these requirements into a conceptual schema of the database. The schema
developed at this conceptual design phase provides a detailed overview of the enterprise.

Srikanth T N, Dept. Of BCA, SRS First Grade College Page 11


Database Management System

 A fully developed conceptual schema also indicates the functional requirements of the
enterprise. In a specification of functional requirement, users describe the kinds of operations
or transactions that will be performed on the data.
 The process of moving from an abstract data model to the implementation of the database
proceeds in two final design phases.
 In the logical design phase, the designer maps the high level conceptual schema
onto the implementation data model or relational data model of the database
system that will be used.
 Finally, the designer uses the resulting system specific database schema in the
subsequent physical design phase, in which the physical features of the database
are specified.
We use the term entity to refer to any such people, places, products etc distinctly
identifiable item. In designing a database schema, we must ensure that we avoid two major
pitfalls.
1. Redundancy: A bad design may repeat information
2. Incompleteness: A bad design may make certain aspects of the enterprise difficult or
impossible to model.

Unified Modeling Language UML


UML has many components to graphically model different aspects of an entire software
system. Binary relationship sets are represented in UML by just drawing a line connecting the
entity sets. The relationship set name is written adjacent to the line.
The role played by an entity set in a relationship set may also be specified by writing the
role name on the line, adjacent to the entity set.
The relationship set name may alternatively be written in a box, along with attributes of
the relationship set, and the box is connected, using a dotted line, to the line depicting the
relationship set.
Some parts of UML are:
 Class diagram
 Use Case diagram
 Activity diagram
 Implementation diagram

Srikanth T N, Dept. Of BCA, SRS First Grade College Page 12


Database Management System

Figure 14: Symbols used in the UML class diagram notation


E-R Diagram for a University Enterprise
Strong Entity Sets: Here the Strong entities are the
 Department
 Instructor
 student
 course
 classroom
 time_slot

Srikanth T N, Dept. Of BCA, SRS First Grade College Page 13


Database Management System

Figure 15: E-R Diagram for a University Enterprise


Weak Entity Sets: Here the weak entity is section.
Relationship Sets: Here the relationships are
 course_dept
 inst_dept
 stud_dept
 advisor
 teaches
 takes
 sec_course
 sec_time_slot
 prereq
 sec_class
Schemas: course= (course_id, title, credits)
department= (dept_name, building, budget)

Srikanth T N, Dept. Of BCA, SRS First Grade College Page 14


Database Management System

Generalization: person= (person_id, name, street, city)


instructor= (ID, name, salary)
student= (ID, name, tot_credits)
Schemas for University Enterprise:
 Schemas derived from a strong entity:
department= (dept_name, building, budget)
instructor= (ID, name, salary)
student= (ID, name, tot_credits)
section= (sec_id, semester, year)
classroom= (building, room_number, capacity)
 Schemas derived from a relationship set
course_dept= (course_id, dept_name)
inst_dept= (ID, dept_name)
stud_dept= (ID, dept_name)
teaches= (ID, sec_id)
takes= (ID, sec_id, grade)
prereq= (course_id, prereq_id)
sec_course= (sec_id, course_id)
sec_time_slot= (sec_id, time_slot_id)
Important Questions
1. Define relation with simple example. Mention different keys used in DBMS & explain.

2. Explain different type’s attributes with example.

3. Write a note on Entity constraints.

4. Explain mapping cardinalities with example.

5. Discuss strong entity set & weak entity set.

6. Explain Generalization & Aggregation with example.

7. Write E-R Diagram for Hospitality management system.

8. Explain Generalization & Specialization with example.

9. Write E-R Diagram for banking enterprises.

10. What is Entity relationship model? Write an E-R Diagram for college database.

Srikanth T N, Dept. Of BCA, SRS First Grade College Page 15

You might also like