Что такое findslide.org?

FindSlide.org - это сайт презентаций, докладов, шаблонов в формате PowerPoint.


Для правообладателей

Обратная связь

Email: Нажмите что бы посмотреть 

Яндекс.Метрика

Презентация на тему Entity relationship model. (Lecture 1)

Содержание

Think before doing it!Like most of the software projects, you need to think before you do something.Before developing your database application, you need to collect the requirements, and build a conceptual model.ER model is a
LECTURE 1:  Entity Relationship MODELDr. Samson Think before doing it!Like most of the software projects, you need AN Entity Relationship (ER) Diagram Looks Like This ER ModelKey concepts of ER modelEntitiesRelationshipsEntity:Is an object that exists and ER ModelEntity Has attributes that describe itnameaddressid ER ModelEntity set:Is the set of entities that share the same properties SamsonDanielLeviDennisInstructorsCoursesCS306CS308MATH204 ER ModelEntity sets may overlapExample?EmployeesManagers ER ModelRelationships:Relate two or more entities (such as Ali is enrolled in CS306) ER ModelRelationships:Relate two or more entities (such as Serafettin is enrolled ER ModelRectangles : Entity setsEllipses    : attributesstudentnamesid ER ModelRectangles : Entity setsEllipses    : attributesstudentCoursenamesidcidcname ER ModelRectangles : Entity setsDiamonds  : Relationship SetsEllipses    : attributesEnrolledstudentCoursenamesidcidcname ER ModelEach entity set has attributes Each attribute has a domain (domain ER ModelEach entity set has attributes Each attribute has a domain (domain ER ModelRelationship sets also have attributes ER ModelEnrolledstudentCoursenamesidcidcname ER ModelRelationship sets also have attributesWe are going to talk about the ER ModelDegree of a relationship set is the number of entity sets ER ModelTernary relationship sets involve three entity setscustomerborrowsloanbranch ER ModelWe may have relationships among the entities that belong to the ER ModelWe may have relationships among the entities that belong to the ER ModelWe may have relationships among the entities that belong to the ER Modelemployerenameeid ER ModelemployerenameeidReports_to ER ModelemployerenameeidReports_tosupervisor ER ModelemployerenameeidReports_tosupervisorsubordinate ER ModelTernary relationship setscustomerloanbranch ER ModelTernary relationship setscustomerborrowsloanbranch Mapping cardinalities1-to-1One-to-One relationship (ex: marriage relationship set between husbands and wives) Mapping cardinalities1-to-11-to ManyOne-to-One (ex: marriage relationship set between husbands and wifes) One-to-Many (example?) Mapping cardinalities1-to-11-to ManyMany-to-1One-to-One (ex: marriage relationship set between husbands and wifes)One-to-Many Many-to-One Mapping cardinalitiesMany-to-Many1-to-11-to ManyMany-to-1One-to-One (ex: marriage relationship set between husbands and wifes)One-to-Many Many-to-OneMany-to-Many Many-to-Many1-to-11-to ManyMany-to-1Consider the works_in relationshipIf an employee can work in multiple departments Many-to-Many1-to-11-to ManyMany-to-1Consider the manages relationshipIf an employee can manage multiple departments but Participation ConstraintsIf every department MUST have a manager, then there is a Participation ConstraintsIf every department MUST have a manager, then there is a Participation ConstraintsIf every employee MUST work in a department, then there is Participation ConstraintsPlus, if every department MUST have employee(s) working in that department, ISA (`is a’) HierarchiesContract_EmpsnamessnEmployeeslothourly_wagesHourly_Empscontractidhours_worked ISA (`is a’) HierarchiesContract_EmpsnamessnEmployeeslothourly_wagesISAHourly_Empscontractidhours_worked ISA (`is a’) HierarchiesContract_EmpsnamessnEmployeeslothourly_wagesISAHourly_Empscontractidhours_workedOverlap constraints: Can Serafettin be an Hourly Employee as Weak EntitiesA weak entity can be identified uniquely only by considering the Weak EntitiesA weak entity can be identified uniquely only by considering the Weak EntitiesA weak entity can be identified uniquely only by considering the Weak EntitiesA weak entity can be identified uniquely only by considering the Weak EntitiesA weak entity can be identified uniquely only by considering the AggregationUsed when we have to model a relationship involving (entitity sets and) Example:Draw the ER diagram for the following specifications: There are conferences, universities, Conceptual Design Using the ER ModelDesign choices:Should a concept be modeled as Entity vs. AttributeShould address be an attribute of Employees or an entity Entity vs. Attribute (Contd.)Works_In2 does not   allow an employee to Binary vs. Ternary RelationshipsIf each policy is owned by just 1 employee:Key Entity vs. RelationshipFirst ER diagram OK if a manager gets a separate Summary of Conceptual DesignConceptual design follows requirements analysis, Yields a high-level description Summary of ER (Contd.)Several kinds of integrity constraints can be expressed in Summary of ER (Contd.)ER design is subjective. There are often many ways Banks Database in North Cyprus You are asked to design a database
Слайды презентации

Слайд 2 Think before doing it!
Like most of the software

Think before doing it!Like most of the software projects, you

projects, you need to think before you do something.
Before

developing your database application, you need to collect the requirements, and build a conceptual model.
ER model is a widely accepted standard for conceptual DB design.


Слайд 3 AN Entity Relationship (ER) Diagram Looks Like This

AN Entity Relationship (ER) Diagram Looks Like This

Слайд 4 ER Model
Key concepts of ER model
Entities
Relationships
Entity:
Is an object

ER ModelKey concepts of ER modelEntitiesRelationshipsEntity:Is an object that exists

that exists and that can be distinguished from other

objects





Samson

CS306

Daniel


Слайд 5 ER Model
Entity Has attributes that describe it
name
address
id

ER ModelEntity Has attributes that describe itnameaddressid

Слайд 6 ER Model
Entity set:
Is the set of entities that

ER ModelEntity set:Is the set of entities that share the same properties SamsonDanielLeviDennisInstructorsCoursesCS306CS308MATH204

share the same properties


Samson
Daniel
Levi
Dennis
Instructors

Courses
CS306
CS308
MATH204


Слайд 7 ER Model
Entity sets may overlap
Example?

Employees
Managers

ER ModelEntity sets may overlapExample?EmployeesManagers

Слайд 8 ER Model
Relationships:
Relate two or more entities (such as

ER ModelRelationships:Relate two or more entities (such as Ali is enrolled in CS306)

Ali is enrolled in CS306)







Слайд 9 ER Model
Relationships:
Relate two or more entities (such as

ER ModelRelationships:Relate two or more entities (such as Serafettin is

Serafettin is enrolled in CS306)
Relationship sets:
Collection of all relationship

sets with the same properties (all student enrollments)
Relationships may also have attributes


Слайд 10 ER Model
Rectangles : Entity sets
Ellipses

ER ModelRectangles : Entity setsEllipses  : attributesstudentnamesid

: attributes
student
name
sid


Слайд 11 ER Model
Rectangles : Entity sets
Ellipses

ER ModelRectangles : Entity setsEllipses  : attributesstudentCoursenamesidcidcname

: attributes
student
Course
name
sid
cid
cname


Слайд 12 ER Model
Rectangles : Entity sets
Diamonds : Relationship

ER ModelRectangles : Entity setsDiamonds : Relationship SetsEllipses  : attributesEnrolledstudentCoursenamesidcidcname

Sets
Ellipses : attributes
Enrolled
student
Course
name
sid
cid
cname


Слайд 13 ER Model
Each entity set has attributes
Each attribute

ER ModelEach entity set has attributes Each attribute has a domain

has a domain (domain is the set of permitted

values)

Слайд 14 ER Model
Each entity set has attributes
Each attribute

ER ModelEach entity set has attributes Each attribute has a domain

has a domain (domain is the set of permitted

values)
Each entity set has a key
Keys are denoted by underlining the attribute name in the ER diagram

Слайд 15 ER Model
Relationship sets also have attributes

ER Model
Enrolled
student
Course
name
sid
cid
cname

ER ModelRelationship sets also have attributes ER ModelEnrolledstudentCoursenamesidcidcname

Слайд 16 ER Model
Relationship sets also have attributes
We are going

ER ModelRelationship sets also have attributesWe are going to talk about

to talk about the key in a relationship set

later on

ER Model

Enrolled

student

Course

name

semester

sid

cid

cname


Слайд 17 ER Model
Degree of a relationship set is the

ER ModelDegree of a relationship set is the number of entity

number of entity sets that participate in a relationship
Binary

relationship sets involve two entity sets

ER Model

Enrolled

student

Course

name

semester

sid

cid

cname


Слайд 18 ER Model
Ternary relationship sets involve three entity sets
customer
borrows
loan
branch

ER ModelTernary relationship sets involve three entity setscustomerborrowsloanbranch

Слайд 19 ER Model
We may have relationships among the entities

ER ModelWe may have relationships among the entities that belong to

that belong to the same entity set
each entity

has a role in such a relationship

student

name

sid

helps



students




Слайд 20 ER Model
We may have relationships among the entities

ER ModelWe may have relationships among the entities that belong to

that belong to the same entity set
each entity

has a role in such a relationship

student

name

sid

helps

tutor

tutee


Слайд 21 ER Model
We may have relationships among the entities

ER ModelWe may have relationships among the entities that belong to

that belong to the same entity set (each entity

has a role in such a relationship)
What is the degree of the following relationship set (2 or 1)?

student

name

sid

helps

tutor

tutee


Слайд 22 ER Model
employer
ename
eid

ER Modelemployerenameeid

Слайд 23 ER Model
employer
ename
eid
Reports_to

ER ModelemployerenameeidReports_to

Слайд 24 ER Model
employer
ename
eid
Reports_to
supervisor

ER ModelemployerenameeidReports_tosupervisor

Слайд 25 ER Model
employer
ename
eid
Reports_to
supervisor
subordinate

ER ModelemployerenameeidReports_tosupervisorsubordinate

Слайд 26 ER Model
Ternary relationship sets
customer
loan
branch

ER ModelTernary relationship setscustomerloanbranch

Слайд 27 ER Model
Ternary relationship sets
customer
borrows
loan
branch

ER ModelTernary relationship setscustomerborrowsloanbranch

Слайд 28

Mapping cardinalities


1-to-1





One-to-One relationship (ex: marriage relationship set between

Mapping cardinalities1-to-1One-to-One relationship (ex: marriage relationship set between husbands and wives)

husbands and wives)


Слайд 29

Mapping cardinalities




1-to-1
1-to Many





One-to-One (ex: marriage relationship set between

Mapping cardinalities1-to-11-to ManyOne-to-One (ex: marriage relationship set between husbands and wifes) One-to-Many (example?)

husbands and wifes)
One-to-Many (example?)




Слайд 30

Mapping cardinalities






1-to-1
1-to Many
Many-to-1





One-to-One (ex: marriage relationship set between

Mapping cardinalities1-to-11-to ManyMany-to-1One-to-One (ex: marriage relationship set between husbands and wifes)One-to-Many Many-to-One

husbands and wifes)
One-to-Many
Many-to-One



Слайд 31

Mapping cardinalities






Many-to-Many


1-to-1
1-to Many
Many-to-1





One-to-One (ex: marriage relationship set between

Mapping cardinalitiesMany-to-Many1-to-11-to ManyMany-to-1One-to-One (ex: marriage relationship set between husbands and wifes)One-to-Many Many-to-OneMany-to-Many

husbands and wifes)
One-to-Many
Many-to-One
Many-to-Many



Слайд 32







Many-to-Many


1-to-1
1-to Many
Many-to-1





Consider the works_in relationship

If an employee can

Many-to-Many1-to-11-to ManyMany-to-1Consider the works_in relationshipIf an employee can work in multiple

work in multiple departments and a department can have

multiple employees

What type of relationship is that?



dname

budget

did

since

name

Works_In

Departments

Employees

ssn











lot


Слайд 33







Many-to-Many


1-to-1
1-to Many
Many-to-1





Consider the manages relationship

If an employee can

Many-to-Many1-to-11-to ManyMany-to-1Consider the manages relationshipIf an employee can manage multiple departments

manage multiple departments but a department has only one

manager

What type of relationship is that?

This is called a key constraint (denoted with an arrow)




dname

budget

did

since

name

Manages

Departments

Employees

ssn











lot


Слайд 34

Participation Constraints
If every department MUST have a manager,

Participation ConstraintsIf every department MUST have a manager, then there is

then there is a participation constraint
The participation of Departments

in Manages is total (otherwise it is partial).











lot



name

dname

budget

did

since

name

dname

budget

did

since

Manages

since

Departments

Employees

ssn

Works_In


Слайд 35

Participation Constraints
If every department MUST have a manager,

Participation ConstraintsIf every department MUST have a manager, then there is

then there is a participation constraint
The participation of Departments

in Manages is total (otherwise it is partial).
Participation constraints are denoted with a thick line (for example each department must participate in the manages relationship, therefore this is denoted with a thick line in the relationship)











lot



name

dname

budget

did

since

name

dname

budget

did

since

Manages

since

Departments

Employees

ssn

Works_In


Слайд 36

Participation Constraints
If every employee MUST work in a

Participation ConstraintsIf every employee MUST work in a department, then there

department, then there is a participation constraint on employee

entity set











lot



name

dname

budget

did

since

name

dname

budget

did

since

Manages

since

Departments

Employees

ssn

Works_In


Слайд 37

Participation Constraints
Plus, if every department MUST have employee(s)

Participation ConstraintsPlus, if every department MUST have employee(s) working in that

working in that department, then there is a participation

constraint on department entity set











lot



name

dname

budget

did

since

name

dname

budget

did

since

Manages

since

Departments

Employees

ssn

Works_In


Слайд 38

ISA (`is a’) Hierarchies
Contract_Emps




name
ssn
Employees
lot

hourly_wages




Hourly_Emps
contractid
hours_worked

ISA (`is a’) HierarchiesContract_EmpsnamessnEmployeeslothourly_wagesHourly_Empscontractidhours_worked

Слайд 39

ISA (`is a’) Hierarchies
Contract_Emps




name
ssn
Employees
lot

hourly_wages





ISA
Hourly_Emps
contractid
hours_worked

ISA (`is a’) HierarchiesContract_EmpsnamessnEmployeeslothourly_wagesISAHourly_Empscontractidhours_worked

Слайд 40

ISA (`is a’) Hierarchies
Contract_Emps




name
ssn
Employees
lot

hourly_wages





ISA
Hourly_Emps
contractid
hours_worked
Overlap constraints: Can Serafettin be

ISA (`is a’) HierarchiesContract_EmpsnamessnEmployeeslothourly_wagesISAHourly_Empscontractidhours_workedOverlap constraints: Can Serafettin be an Hourly Employee

an Hourly Employee as well as a Contract Employee?
Covering

constraints: Does every Employee also have to be an Hourly Employee or a Contract Employee?
Reasons for using ISA:
To add descriptive attributes specific to a subclass.
To identify entities that participate in a relationship.
Specialization vs. generalization

Слайд 41

Weak Entities

A weak entity can be identified uniquely

Weak EntitiesA weak entity can be identified uniquely only by considering

only by considering the primary key of another (owner)

entity.








lot

name

age

pname

Dependents

Employees

ssn

Policy

cost




Слайд 42

Weak Entities
A weak entity can be identified uniquely

Weak EntitiesA weak entity can be identified uniquely only by considering

only by considering the primary key of another (owner)

entity.
A weak entity set is denoted by a rectangle with thick lines








lot

name

age

pname

Dependents

Employees

ssn

Policy

cost




Слайд 43

Weak Entities
A weak entity can be identified uniquely

Weak EntitiesA weak entity can be identified uniquely only by considering

only by considering the primary key of another (owner)

entity.
A weak entity set is denoted by a rectangle with thick lines
The relationship between a week entity and the owner entity is denoted by a diamond with thick lines.










lot

name

age

pname

Dependents

Employees

ssn

Policy

cost



Слайд 44

Weak Entities
A weak entity can be identified uniquely

Weak EntitiesA weak entity can be identified uniquely only by considering

only by considering the primary key of another (owner)

entity.
What can you say about the constraints on the indentifying relationship? (i.e., participation and key constraints)









lot


name

age

pname

Dependents

Employees

ssn

Policy

cost


Слайд 45

Weak Entities
A weak entity can be identified uniquely

Weak EntitiesA weak entity can be identified uniquely only by considering

only by considering the primary key of another (owner)

entity.
Owner entity set and weak entity set must participate in a one-to-many relationship set (one owner, many weak entities).
Weak entity set must have total participation in this identifying relationship set.









lot


name

age

pname

Dependents

Employees

ssn

Policy

cost


Слайд 46

Aggregation
Used when we have to model a relationship

AggregationUsed when we have to model a relationship involving (entitity sets

involving (entitity sets and) a relationship set.
Aggregation allows us

to treat a relationship set as an entity set for purposes of participation in (other) relationships.

Aggregation vs. ternary relationship:
Monitors is a distinct relationship,
with a descriptive attribute.

Also, can say that each sponsorship
is monitored by at most one employee.












budget

did

pid

started_on

pbudget

dname

until

Departments

Projects

Sponsors

Monitors





lot

name

ssn


since


Слайд 47 Example:
Draw the ER diagram for the following specifications:

Example:Draw the ER diagram for the following specifications: There are conferences,

There are conferences, universities, and professors. Conferences have names

(such as VLDB, ICDE, SIGMOD), and years they are organized. A conference can be organized in different years but a conference can not be organized more than once in a certain year. For example SIGMOD is organized in 2001, 2002, etc, but SIGMOD can not be organized twice in 2001.Universities have names and cities they are located, such as Sabanci Universiy located in Istanbul. Each conference at a specific year is organized by one university, but a university can organize many conferences. Each conference organized at a specific year has a list of PC (Program Committee) members which consists of professors associated with universities. Professors have names and SSNs. A professor is associated with one university, but a university may have many professors.

Слайд 48

Conceptual Design Using the ER Model
Design choices:
Should a

Conceptual Design Using the ER ModelDesign choices:Should a concept be modeled

concept be modeled as an entity or an attribute?
Should

a concept be modeled as an entity or a relationship?
Identifying relationships: Binary or ternary? Aggregation?
Constraints in the ER Model:
A lot of data semantics can (and should) be captured.
But some constraints cannot be captured in ER diagrams.

Слайд 49 Entity vs. Attribute
Should address be an attribute of

Entity vs. AttributeShould address be an attribute of Employees or an

Employees or an entity (connected to Employees by a

relationship)?
Depends upon the use we want to make of address information, and the semantics of the data:
If we have several addresses per employee, address must be an entity (since attributes cannot be set-valued).
If the structure (city, street, etc.) is important, e.g., we want to retrieve employees in a given city, address must be modeled as an entity (since attribute values are atomic).

Слайд 50

Entity vs. Attribute (Contd.)
Works_In2 does not

Entity vs. Attribute (Contd.)Works_In2 does not  allow an employee to

allow an employee to work in a department

for two or more periods.
Similar to the problem of wanting to record several addresses for an employee: we want to record several values of the descriptive attributes for each instance of this relationship.


Works_In2



from

to



budget

Departments







name

Departments

ssn

lot

Employees

Works_In3


Слайд 51

Binary vs. Ternary Relationships
If each policy is owned

Binary vs. Ternary RelationshipsIf each policy is owned by just 1

by just 1 employee:
Key constraint on Policies would mean

policy can only cover 1 dependent!





age

pname

Dependents

Covers




age

pname

Dependents

Purchaser


Bad design

Better design


Слайд 52

Entity vs. Relationship
First ER diagram OK if a

Entity vs. RelationshipFirst ER diagram OK if a manager gets a

manager gets a separate discretionary budget for each dept.
What

if a manager gets a discretionary budget that covers all managed depts?
Redundancy of dbudget, which is stored for each dept managed by the manager.
Misleading: suggests dbudget tied to managed dept.












Manages2

name

dname

budget

did

Employees

Departments

ssn

lot

dbudget

since


Слайд 53

Summary of Conceptual Design
Conceptual design follows requirements analysis,

Summary of Conceptual DesignConceptual design follows requirements analysis, Yields a high-level


Yields a high-level description of data to be stored


ER model popular for conceptual design
Constructs are expressive, close to the way people think about their applications.
Basic constructs: entities, relationships, and attributes (of entities and relationships).
Some additional constructs: weak entities, ISA hierarchies, and aggregation.
Note: There are many variations on ER model.

Слайд 54

Summary of ER (Contd.)
Several kinds of integrity constraints

Summary of ER (Contd.)Several kinds of integrity constraints can be expressed

can be expressed in the ER model: key constraints,

participation constraints, and overlap/covering constraints for ISA hierarchies. Some foreign key constraints are also implicit in the definition of a relationship set.
Some constraints (notably, functional dependencies) cannot be expressed in the ER model.
Constraints play an important role in determining the best database design for an enterprise.

Слайд 55

Summary of ER (Contd.)
ER design is subjective. There

Summary of ER (Contd.)ER design is subjective. There are often many

are often many ways to model a given scenario!

Analyzing alternatives can be tricky, especially for a large enterprise. Common choices include:
Entity vs. attribute, entity vs. relationship, binary or n-ary relationship, whether or not to use ISA hierarchies, and whether or not to use aggregation.
Ensuring good database design: resulting relational schema should be analyzed and refined further. FD information and normalization techniques are especially useful.

  • Имя файла: entity-relationship-model-lecture-1.pptx
  • Количество просмотров: 154
  • Количество скачиваний: 0