2 Entity-Relationship Diagram For Given Application
2 Entity-Relationship Diagram For Given Application
Laboratory Manual
Subject:- Database Management System (DBMS)
Class:-T.E.Computer Semester-II
Experiment No:-02
Theory: -
Real World Object in the database
we talked about “structure” and “instance” of a structure. A model is a higher level name of a structure.
A structure is a more formal representation of a model. For example “structure of a house” and “model of a
house” represent the same thing but the structure gives more information about the construction of the house
compared to its model.
Mini world Example: Company
System
independent Component identification Example: Departments, location, etc.
steps
Example: How communication flows
How components are related? among departments.
Example: Illustration of
Conceptual design components and which is related
to what and how.
Outcome: A semantic model of
Conceptual schema
the miniworld
System
Example: How the model is
dependent
steps Data model mapping mapped to a logical structure
which can be stored in the
database.
Any object or entity has its own structure. For example, a table or a chair or a human being has a
unique structure. The process uses a tool which describes the entity in terms of smaller components and its
semantics. For example, the model of a chair must describe its semantics (e.g., it is an entity where people sit)
and must identify smaller components (legs, back, etc.) and their inter-relationship. Such modeling tools are
called “Semantic Data Modeling”. One such tools, which is referred to as “Entity-Relationship” model.
Mini world: A part of the real world for which you design a database. Our example: A Company. The
company performs a set of functions through a number of departments. The company can be a bank, a
manufacturing plant, or an airline. We describe the structure of the company in terms of a number of
components.
Component identification: The company has a set of departments = {D1, D2, ..., Dn}. Each department has a
specific role, specific function, and can be identified by a set of attributes. The company may have a number of
branches which may be located at various locations. Each branch may have its own set of departments; thus the
structure is identical.
How components are related: Department D1 may or may not be dependent on department D2. If dependent
then the existence of D1 will dependent on the existence of D2. If D2 closes then D1 must close as well. For
example if the production department of a company closes down the sales department must also go.
Data collection: To identify and deal with a department a set of meaningful attributes for each department is
selected. Some example attributes are: Dname, Dnumber, Dmanager, Dmanager Start date, Dept. locations,
etc. Each department has specific functions. For example sales department has some specific functions,
production department has a set of functions such as projects, completion date of each project, and so on.
Necessary data about these function-sets must be collected.
Conceptual design: A semantic modeling tool uses above information to build a model of the company. A
good model is able to answer questions such as (a) How many departments are in this company, (b) What is the
name of the company, (c) What the projects manages by this company, (d) What is the function of sales
department, and so on. These components are related to each other in a variety of ways. A relationship can be
categorized into (a) One to one (1:1), (b) One to many (1:N), and (b) Many to many (M:N).
One to One (1:1): The instance of one entity is related to only one instance of another entity with some
relationship type. For example, one employee works in one department. The association of the employee with
the department is 1:1.
One to Many (1:N): An instance of an entity (E) is related with only one instance of another entity (F) but F is
related to many instances of E.
Many to Many (M:N): An instance of an entity E is related to many instances of entity F and one instance of
F is related to many instances of E.
d1
e1 r1
e2
d2
r2
e3 d3
r3
e4 r4
. .
Instances of relationship type Work_for, Employee, and Department and their relationship
Degree of a Relationship Type
In reality (a) only two entities are related together or (b) more than two entities are related
together. This kind of situation is defined by “degree of a relationship” type. Thus, it defines
how many entity types are related with a relationship type.
Binary relation: In this relationship type only two entity types are related with a relationship
type.
Example: entity type Employee and entity type Department are related with Works_For
relationship type. Note that only Employee and Department entities are involved in this relation,
there is no third entity.
Ternary relation: In this relationship type, three entities (not two and not four) are related with
a relationship type.
Example 1
Entity types: Supplier (S), Part (P), and Project (J).
Relationship types: Uses and Supplies
Participation constraint: Specifies that the existence of an entity type depends on the existence
of another related entity type. This constraint exists in two ways: (a) Total participation and (b)
Partial participation.
Total participation: This participation exists when all instances of an entity type are related to
one instance of an entity type. For example, every employee works_for a department. Thus, an
employee exists only if a department exists. So the participation of an employee is total in
works_for relationship. Review: Give another example of total participation between entity
types“Project” and “Department”.
Partial participation: This participation exists when one of the instances of an entity type is
related to an instance of another entity type. For example, one of the employees (Manager)
manages a department. It is not true that every employee manages a department. This implies
that the existence of an employee type does not necessarily mean the existence of manages
relationship for the employee. So the participation of an employee in manages is partial.
Together Cardinality ratio and Participation constraints are termed as Structural
Constraints.
1 N
Entity1 R Entity2 Example: A student has multiple degrees,an employee has multiple phone
numbers,etc.