reflexive rela 1 tionships n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Reflexive Rela 1 tionships PowerPoint Presentation
Download Presentation
Reflexive Rela 1 tionships

Loading in 2 Seconds...

play fullscreen
1 / 19

Reflexive Rela 1 tionships - PowerPoint PPT Presentation


  • 63 Views
  • Uploaded on

Reflexive Rela 1 tionships. An entity may be related to another entity of the same type. Example: A Customer could have Children, who are also Customers. Joe Doe is Jane Doe’s father. Bob Doe is Jane Doe’s son. Child. Joe Doe. Jane Doe. Child. Sue San. Bob Doe. Customer.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Reflexive Rela 1 tionships' - joanna


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
reflexive rela 1 tionships
Reflexive Rela1tionships
  • An entity may be related to another entity of the same type.
    • Example: A Customer could have Children, who are also Customers. Joe Doe is Jane Doe’s father. Bob Doe is Jane Doe’s son.

Child

Joe Doe

Jane Doe

Child

Sue San

Bob Doe

Customer

--The Entity Relationship Model(2)--

reflexive relationship types diagram
Reflexive Relationship Types - Diagram
  • Relationship type connects to self in an ER diagram.

Children

Customer

--The Entity Relationship Model(2)--

kinds of relationship types
Kinds of Relationship Types
  • How many of each entity type participate in a relationship type?
    • 1-1
    • 1-many
    • many-1
    • many-many
  • Total vs. Partial participation
    • Total participation means that every entity participates in the relationship.
    • Partial means that some entities might not participate.
    • Bounds (min-max) on participation
  • (At least) three different “diamond” notations
    • Arrow vs. straight line with or without participation bounds
    • DO NOT MIX NOTATIONS!

--The Entity Relationship Model(2)--

an example one to one relationship type
An Example One-to-One Relationship Type
  • A Customer might be an Employee.
  • An EmployeeIsACustomer.
  • Participation is total on the Employee side in this example.

Customer

IsA

Employee

--The Entity Relationship Model(2)--

diagramming one to one rel types
Diagramming One-To-One Rel. Types

B

  • An element in A is associated with at most one element in C via the relationship B. An element in C is associated with at most one element in A via B.

(0,1)

(0,1)

A

C

B

1

1

A

C

B

A

C

--The Entity Relationship Model(2)--

dvd store database example

IsA

1

1

Employee

Customer

DVD Store Database Example
  • An employee can also be a customer.
  • EachCustomerentity can be matched with at most oneEmployeeentity, and eachEmployeeentity can be matched with at most oneCustomerentity (both entities represent the same person).
  • Often this can be better represented using additional attributes, or by using subclasses (wait a few slides!)

--The Entity Relationship Model(2)--

total vs partial participation
Total vs. Partial Participation
  • Use a double line to indicate total participation.
  • Example: EveryAis in aBrelationship with exactly oneC, but someC’smay be unrelated to anA.
  • Using participation constraints, total participation is a 1 on the minimum bound.

B

1

1

A

C

B

(1,1)

(0,1)

A

C

--The Entity Relationship Model(2)--

an example one to many relationship type
An Example One-to-Many Relationship Type
  • A CustomerRents zero to several DVD copies.
  • A DVD copy can be Rented by at most one Customer.
  • Participation is partial on both sides in this example.

Customer

Rents

DVD copy

--The Entity Relationship Model(2)--

one to many relationship
One-To-Many Relationship
  • An element in A is associated with several (including 0) elements in C via B. An element in C is associated with at most one element in A via B.

B

(0,m)

(0,1)

A

C

B

1

m

A

C

B

A

C

--The Entity Relationship Model(2)--

dvd store database example1

Rents

1

m

Customer

DVD copy

DVD Store Database Example
  • A Customer might not be related to a DVD copy entity.
  • Each DVD copy entity is associated with at most one Customer entity.

--The Entity Relationship Model(2)--

an example many to many rel type
An Example Many-to-Many Rel. Type
  • A PerformerStars In one or many Films.
  • A Film can Star zero to many Performers.
  • Participation is total on the Performer in this example.

Performer

Stars In

Film

--The Entity Relationship Model(2)--

many to many relationship
Many-To-Many Relationship

B

  • An element in A is associated with several elements in C via B.
  • An element in C is associated with several elements in A via B.

(0,m)

(0,n)

A

C

B

n

m

A

C

B

A

C

--The Entity Relationship Model(2)--

dvd store database example2

Name

FilmID

Stars

In

m

n

Performer

Film

Role

DVD Store Database Example

--The Entity Relationship Model(2)--

roles

(0,20)

parent

Children

Customer

(0,2)

child

Roles
  • Definition: A role is a label on a relationship type edge.
  • Example: labels "parent" and "child" are roles.
  • Roles are optional, and are used to clarify semantics of a relationship type.

--The Entity Relationship Model(2)--

weak entity types

Copy #

Title

Status

Copies

1

m

Film

DVD copy

Weak Entity Types
  • Definition: A weakentity type borrows key attributes from another entity type (called the owning or strong entity type) to uniquely identify entities.
    • Example: A DVD copy has a Copy #, relative to a Film title (e.g., `Babe copy 1’, `Babe copy 2’, `Finding Nemo copy 1’. Copy # is not a key, but combined with Title it is (for DVD copy).
  • ER diagram - double box represents weak entity type.
  • The existence of aDVD copyentity depends on the existence of aFilmentity.

--The Entity Relationship Model(2)--

weak entity type partial keys
Weak Entity Type – Partial Keys
  • A weak entity type has a partial key (key is completed by borrowing key attributes from owning entity type(s)).
    • Example: Key for Video Tape is (Title, Copy#).
  • ER diagram - partial key represented with dashed line.

Copy #

Title

Status

Copies

1

m

Film

DVD copy

--The Entity Relationship Model(2)--

weak entity type cont
Weak Entity Type, cont.
  • Semantics:
    • Deletion of a Film entity requires deletion of that film's DVD copy entities.
  • A weak entity is related to precisely one entity in the owning entity type, via a 1-1 or 1-many relationship.
  • It is possible to introduce more attributes to the DVD copy entity type, so that a primary key will exist, but they may not be needed for database processing.

--The Entity Relationship Model(2)--

cascaded weak entity types
Cascaded Weak Entity Types
  • Weak entity types can be cascaded:
  • Semantics:
    • To delete anemployee, the family's dependents and their medical records must also be deleted.

Dependent Name

Gender

Name

Phone

emp

fam

1

m

Employee

Dependent

1

Fam

med

SSN

Visit Num

m

Medical Record

Date

a video store er schema
A Video Store ER Schema

NumCheckOuts

AmountPaid

CustomerID

TotalRes

CopyNum

Status

ReturnDate

Status

parent (0,n)

Children

Rents

1

m

Customer

DVD

m

child (0,2)

m

Name

Reserves

Copies

Address

Street

n

1

City

State

FilmID

Title

StarsIn

n

m

Kind

Performer

Film

RentalPrice

Date

Name

Role

Distributor

Director