Sei sulla pagina 1di 17

Element of E-R Model

Entity
An entity is a person, place, thing or event for which the data is collected and
maintained. Some example of entity is as follow
Teacher
Person: Teacher, Student, Doctor
Place: Country, City, Province
Object: Vehicle, Toy, Furniture
Event: Purchase, Admission, Registration

Entity Type
A set of entity with same attributes is called entity type. It is also known as
entity class. For example, student entity type has attribute like name, roll no and
age etc.

Entity Instance
A member of an entity class is known as an entity instance. It is also known
as entity occurrence. For example class representative (CR) is an entity instance in
entity type Student.

Entity Set
A set of all entities of a particular entity type in the database at a
given point of time is called an entity set. For example an entity set student
contains all students in the university.
Note: Normally same name is used for both entity type and entity set.

Weak Entity
An entity that exists only if another entity exists is known as weak
entity. It means that a week entity depend upon the existence of another
entity.

Strong Entity
An entity that can exist without the existence of another entity is
known as strong entity. A strong entity is also known as parent, owner or
dominant entity.

Class

Fig: Strong Entity Class and Weak Entity Students

For example parent entity and child entity or Class entity and Student
entity. In the above example parent and class are strong entity and child and
students are week entity because they depend upon parent and Class
respectively for their existence. A relationship between strong and weak
entity is identifying relationship.

Associative Entity
Associative entity is a type of entity that associates the instance of one
or many entity types with one another. The attribute of associative represent
the relationship between the entity instances.

Fig: Associative Entity

Professors
Fig: Associative Entity

Attributes
The characteristics of an entity are called attributes or properties. For
example name, address, class and email of a student are his attributes.

Attribute Domain
An attribute domain is a set of possible values for an attribute. All attribute
have domain. The domain may consist of a range of values or some discrete values.
For example Grade Point Average (GPA) can only be from 0 to 4.

Simple Attributes
An attribute that cannot be subdivided into smaller component is known as
simple attribute or atomic attribute. For example a person can have only one
gender and data of birth.
Name

Student

Composite Attributes
An attribute that can be subdivided into smaller component is known as
composite attribute. For example address can be subdivided into street, city and
country.
City
Street
Country

Address

Employee

Single-Valued Attribute
An attribute that may contain single value is called single-value attribute. For
example, age or gender of a person is single-value attribute.

Multi-Valued Attribute
An attribute that may contain two or more values is called multi-value
attribute. For example, a persons degrees, employees skill or persons profession.

Street

City

Country

Emp_ID
Address

Employee

Stored Attributes
An attribute that is stored in the database is called stored attribute.
Most of the attributes are stored attributes.

Derived Attributes
An attribute which is not stored in database but derived from another
value is called derived attribute. For example you can calculate age of a
person from date of birth.

Identifiers
Identifier is an attribute that identifies an entity instance among other
instance in entity set. For example there may be many instances of student
entity set. But a student is uniquely identified by student ROLLNO.
RollNo

An identifier can be unique or non-unique. Similarly an identifier can be


simple or composite. It is simple if it consists of one attribute and it is
composite if it consists of two or more attributes.

Relationships
A relationship is a logical connection between different entities. The
entities that participate in a relationship are called participants. The

relationship may be between different entities or between an entity and


itself.

Degree of Relationship
A relationship may consist of many entities. The number of entities in a
relationship is called degree of relationship.

Unary Relationship
Unary relationship is a type of relationship that is established between
the instances of same entity type. This is also known as recursive
relationship.

Player

Plays
with

Student

Study
with

Lives with
Teacher

Binary Relationship
Binary relationship is a type of relationship that exists between two
entity types.

One-to-One Relationship

This type of relationship is exist when for each instance in first entity
type there is only one instance in the second entity type and for each
instance of second entity type there is only one instance in the first entity
type.

Country

Has

President

One-to-Many Relationship
This type of relationship is exist when for each instance in first entity
type there can be many instances in the second entity type and for each
instance of second entity type there is only one instance in the first entity
type.

Country

Has

City

Many-to-Many Relationship
This type of relationship is exist when for each instance in first entity
type there can be many instances in the second entity type and for each
instance of second entity type there can be many instance in the first entity
type.

Student

Studies

Course

Ternary Relationship
Ternary relationship is a type of relationship that exists among the
instances of three entity types.

DBA

works on

Project

Software
Eng.

Cardinality Constraints
The maximum number of relationship is called cardinality. The
cardinality constraint specifies the number of instance of one entity that can
be associated with each instance of the other entity. Three symbols normally
used

A circle means zero.


A line means one.
A crows foot symbol means many.

Minimum Cardinality
The minimum number of instances of one entity that may be
associated with each instance of another entity is known as minimum
cardinality.
If minimum cardinality is zero we say that it is optional. If the minimum
cardinality is 1 then we say that it is mandatory.

Maximum Cardinality
The maximum number of instances of one entity that may be
associated with each instance of another entity is known as maximum
cardinality. It can be either One or Many.

Optional One

Optional Many

Mandatory One

Mandatory Many

Subtype and Supertype Entities.


Human

Muslim

NonMuslims

In the above example individual and organization is the subtype of


customer. It means that customer is super type of both the individual and
organization. The curve in the line indicates that it is a subtype. The symbol E
also indicates a subtype. This structure of super and subtype are also called
generalization hierarchies because customer is a generalization of both
individual and organization. It is also known as IS-A relationship because
individual is a customer and organization also is a Customer.
Generalization.
Generalization is a process of identifying more general entity types. For
example Human is a more general entity type than Muslim and Non Muslim.
The entity type Human contains attribute that are more general than other
two entity types for example Name, Age and Gender.
Specialization.

Specialization is a process of identifying more specific entity type. For


example Muslim and Non Muslim is a more specific entity type than Human.
The entity type Muslim contains attribute that are more specific to Muslim
entity type than Human entity type for example IsScholar, ZakatPayer Etc.

Projects:
A company has a number of employees. Each employee may
be assigned to one or more project or may not be assigned
to a project. A project must have at least one employee
assigned and may have several employees assigned.
Employee

Assigned to

Project

A hospital has a patient history. Each patient has one or


more history records. Each patient history record belongs to
exactly one patient.

Patient

Has

Record

An account can be charged against many projects


though it may not be changed against any. A project
must have at least one accounts charged against it.
It may have many accounts charged against it.

Account

Charged to

Project

An employee must manage exactly one department. A


department have atleast one employee to manage it.

Employee

Managess

Departmen
t

A department employs many persons. A person is employed


by one department at most.

Employs
Departmen
t
manager
manages one department

Person

A
at most. A department
is managed by one manager at most.

Manager

Manages

Departmen
t

A team consists of many players. A player plays for only one


team.

Team

Employs

Player

A lecturer teaches one course at most. A course is taught by


exactly on lecturer.

Lecturer

Teacher

Course

A purchase order may be for many products. A product may


appear on many purchase orders.

Purchase
order

Contains

Product

In school a student may be assigned one or more post like


perfect, monitor or chairman. A post must be assigned to
exactly one student. A student id identified with student ID,
name, address and Date of birth. A post is identified with
post_id and name. Draw ER diagram to show relationship
between Student and Post with cardinality.
Stud_ID

Post_ID

Name

Assigned to

Students

Address

Date_Birth

Post

Post_Name

In a school a teacher teaches one or more classes. Each


class is taught by one or more teachers. A teacher is
identified with teachers ID as identifier and name. A class is
identified with class code and location. Draw ER diagram to
show relationship between TEACHER and CLASS with
cardinality.
Class_code

Teacher_ID

Teacher

Name

Teaches

Class

Location

A company has a number of employees. The attribute of


employee include employee_id (identifier), name, address
and birthday. The company also has several projects with
attribute project_id (identifier), project_name and start_date.
Each employee may be assigned to one or more project or
may not be assigned to a project. A project must have at
least one employee assigned and may have any number of
employees assigned. An employee billing rate vary from
project to project and company record the BILL_RATE for
each employee when assigned to a particular project.
Emp_ID

Name

Is_Assigned

Employee

DateBirth

Address

Proj_ID

Billing_Rate

Project

Proj_ID

Proj_Name

A university has large no of courses to offer. Course attribute


includes Course_name, Course_No and units. Each course
may have one or more courses as prerequisites or may have
no prerequisites. Similarly a particular course may be a
prerequisites for any number of courses or may not be
prerequisite for any other course.
Course_No

Course_Name

Course

Is_prerequisite

Units

A laboratory has several chemists who work on one or more


projects. Chemist also may use several type of equipment on
each project. Attribute of chemist include Employee_ID
(identifier), Name and phone_no. Attribute of Project includes
Project_ID (identifier) and start_Date. Attribute of equipment
include serial_no and Cost. The organization also wishes to
record Assign_Date i.e. the data when equipment item was
assigned to a particular chemist working on a particular
project. A chemist must be assign to at least one project and
one equipment item. An equipment item needs not to be
assigned and a given project need not be assigned either a
chemist or an equipment item.

Emp_ID

Name

Chemist

Phone

Proj_ID

Assign_Date

Assigned

Project

Equipment

Start_Date

Serial_No

Cost

A college course may have one or more dependent


scheduled sections or may not have a schedule section.
Attributes of Course include Course_ID, Course_Name, and
units. Attributes of SECTION includes Section_Name and
Semester_ID. Semester_ID is composed of two pairs:
Semester and Year. Section_Number is an integer such as 1
or 2 that distinguishes one section from another for the
same course but does not uniquely identify a section.

COURSE

Units

Section_NO

Name

Course_ID

Has_Scheduled

Semester_ID

Semester

Year

A hospital has a large number of registered physicians.


Attribute of Physician include Physician and Specialty.
Patients are admitted to the hospital by physician. Attribute

of PATIENT include Patient_ID and Patient_Name. Any


admitted must have exactly one admitting physician. A
physician may admit any number of patients. Once
admitted, a given patient must be treated by at least one
physician. A particular physician may treat any number of
patients or may not treat any patients. Whenever a patient is
treated by a physician, the hospital records the details of the
treatment (Treatment_date). Component of treatment_Detail
include Date, Time and results.

Admits

Physician_ID

Patient_ID

Physician

Patient

Patient_Name

Treats

Speciality

Treatment_Detail

Date

Results
Time

The firm has a number of sales offices in several states.


Attribute of sale office include office_no (identifier) and
Location. Each sale office is assigned one or more
employees. Attribute of employee are employee_id
(identifier) and employee_Name. An employee must be
assigned to only one sale office.
For each sale office there is always one employee assigned
to manage that
office. An employee may manage only the
sales office to which he is
assigned.
The firm also lists property for sale. Attribute of property are
property_ID
(identifier) and Location. Component of location
includes address, city,
state and zip_code. Each unit of
property must be listed with only one of the sales office. A sale
office may have any number of properties listed, or
may have
no properties listed.
Furthermore each unit of property has one or more owners.
Attributes of
owners are owner_id(identifier) and owner_name.
An owner may own one or more units of property. An attribute of
the relationship between property and owner is percent_Owned.

IsAssigned

Office_No

Sale Office

Location

Employee_ID

Employee

Manages

Employee_Name

Lists
Property_ID
Property

Location

Address
City
State

Parcent_
Owner

Zip_Code
Owns
Owner_ID
Owner

Owner_Name

Potrebbero piacerti anche