Session 2
This presentation is the property of its rightful owner.
Sponsored Links
1 / 31

Session 2 PowerPoint PPT Presentation


  • 32 Views
  • Uploaded on
  • Presentation posted in: General

Session 2. Welcome : To the fourth learning sequence “ Entity-Relationship Model “ E-R Model Recap : In the previous learning sequences, we discussed the basic definitions of Data base subject.

Download Presentation

Session 2

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Session 2

Session 2

Welcome: To the fourth learning sequence

“ Entity-Relationship Model “

E-R Model

Recap : In the previous learning sequences, we discussed the basic definitions of Data base subject.

Present learning: We shall explore the following definitions:

- Purpose of E-R MODEL.

- E-R Diagram.

- Entity & Attributes.

- Relations.


Entity relationship model 1

Entity-Relationship Model1

E-R Diagrams


Purpose of e r model

Purpose of E/R Model

  • The E/R model allows us to sketch the design of a database informally.

  • Designs are pictures called entity-relationship diagrams.

  • Fairly mechanical ways to convert E/R diagrams to real implementations like relational databases exist.


Entity sets

Entity Sets

  • Entity = “thing” or object.

  • Entity set = collection of similar entities.

    • Similar to a class in object-oriented languages.

  • Attribute = property of an entity set.

    • Generally, all entities in a set have the same properties.

    • Attributes are simple values, e.g. integers or character strings.


E r diagrams

E/R Diagrams

  • In an entity-relationship diagram, each entity set is represented by a rectangle.

  • Each attribute of an entity set is represented by an oval, with a line to the rectangle representing its entity set.


Example

name

Adviser

Student

Example

  • Entity set Student has two attributes, name and Adviser.

  • Each Student entity has values for these two attributes, e.g. (Ahmad, Kazem)


Relationships

Relationships

  • A relationship connects two or more entity sets.

  • It is represented by a diamond, with lines to each of the entity sets involved.


Example1

name

addr

name

code

Teachers

Courses

teaches

- Teachers are

teaching some

courses.

Number

- Students take

some courses.

Advises

Takes

- Teachers advises

some students.

Students

name

addr

Example


Relationship set

Relationship Set

  • The current “value” of an entity set is the set of entities that belong to it.

    • Example: the set of all students in our database.

  • The “value” of a relationship is a set of lists of currently related entities, one from each of the related entity sets.


Example2

Example

  • For the relationship Teaches, we might have a relationship set like:

Teachers Courses

Ahmad C++

Samir Math

Ahmad Java

Amer Internet

Samir Algorithms

Jaber Math

Ramez C++


Multiway relationships

Multiway Relationships

  • Sometimes, we need a relationship that connects more than two entity sets.

  • Suppose that students will only take certain courses taught by certain teachers.

    • Our three binary relationships teaches, advises, and takes do not allow us to make this distinction.

    • But a 3-way relationship would.


Example3

Example

name

addr

name

code

Teachers

Courses

number

Preferences

Students

name

addr


A typical relationship set

A Typical Relationship Set

TeacherStudentCourse

AhmadIssam C++

Ahmad NourC++

Ahmad NourJava

Amer IssamInternet

Samir Samar Math

Samir Issam Math

Samir NaderAlgorithms


Many many relationships

Many-Many Relationships

  • Think of a relationship between two entity sets, such as Teaches between Teachers and Courses.

  • In a many-many relationship, an entity of either set can be connected to many entities of the other set.

    • E.g., a teacher teaches many courses; a course is taught by many teachers.


In pictures

In Pictures:

many-many


Example of many many relationship

* Example of Many-Many Relationship

A customer is associated with several (possibly 0) loans via borrower

A loan is associated with several (possibly 0) customers via borrower


Many one relationships

Many-One Relationships

  • Some binary relationships are many -one from one entity set to another.

  • Each entity of the first set is connected to at most one entity of the second set.

  • But an entity of the second set can be connected to zero, one, or many entities of the first set.


In pictures1

In Pictures:

many-one


Example4

Example

  • Advises, from Teachers to Students is One-Many.

  • A student has at most one adviser.

  • But a teacher can be the adviser of any number of students, including zero.


Example of many one relationship

* Example of Many-One relationship

In a many-to-one relationship a loan is associated with several (including 0) customers via borrower, a customer is associated with at most one loan via borrower


One one relationships

One-One Relationships

  • In a one-one relationship, each entity of either entity set is related to at most one entity of the other set.

  • Example: Relationship Is-in between entity sets Teachers and Offices.

    • A teacher cannot be in more than one office, and no office can have more than one teacher (assume this).


In pictures2

In Pictures:

one-one


Example of one one relationship

* Example of One-One relationship

-A customer is associated with at most one loan via the relationship borrower

A loan is associated with at most one customer via borrower


Representing multiplicity

Representing “Multiplicity”

  • Show a many-one relationship by an arrow entering the “one” side.

  • Show a one-one relationship by arrows entering both entity sets.


Example5

Example

Likes

Students

Courses

Favorite


Attributes on relationships

Attributes on Relationships

  • Sometimes it is useful to attach an attribute to a relationship.

  • Think of this attribute as a property of tuples in the relationship set.


Example6

Example

Takes

Students

Course

Date

Date is a function of both the student and the course, not of one alone.


Roles

Roles

  • Sometimes an entity set appears more than once in a relationship.

  • Label the edges between the relationship and the entity set with names called roles.


Example7

Relationship Set

HusbandWife

BobAnn

JoeSue

……

Married

husband

wife

Teachers

Example


E r diagram

E-R Diagram

Summary: In this learning sequence, we discussed the principles of Entity- Relationship diagram.


Session 2

END


  • Login