relationships copyright © 1999 patrick mcdermott uc berkeley extension [email protected] mary...

14
Relationships Copyright © 1999 Patrick McDermott UC Berkeley Extension [email protected] Mary Cassatt (1844–1926) Mother and Child against a Green Background 1887

Upload: emmeline-bailey

Post on 13-Dec-2015

221 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Relationships Copyright © 1999 Patrick McDermott UC Berkeley Extension pmcdermott@msn.com Mary Cassatt (1844–1926) Mother and Child against a Green Background

RelationshipsCopyright © 1999 Patrick McDermott

UC BerkeleyExtension

[email protected]

Mary Cassatt (1844–1926)Mother and Child against a Green Background

1887

Page 2: Relationships Copyright © 1999 Patrick McDermott UC Berkeley Extension pmcdermott@msn.com Mary Cassatt (1844–1926) Mother and Child against a Green Background

ConnectionsCRC Cards: CollaborationERD: Relationship Relational: Foreign KeyDatabase: Database Key Programmer: Pointer, Array, ContainmentUML: AssociationEtc., etc., etc.…: Set, Pairing,

Parent/Child, Owner/MembersSome track: Aggregation, Composition

Page 3: Relationships Copyright © 1999 Patrick McDermott UC Berkeley Extension pmcdermott@msn.com Mary Cassatt (1844–1926) Mother and Child against a Green Background

Types

1. Existence ∃– Employee has Dependent Children– Auto has AirConditioner

2. Functional– Professor teaches Class– Customer Registers

3. Event– Customer places Order– Auto Accident Happens

Page 4: Relationships Copyright © 1999 Patrick McDermott UC Berkeley Extension pmcdermott@msn.com Mary Cassatt (1844–1926) Mother and Child against a Green Background

STUDENT

NameAddressTelephoneEnroll()Party()Flunk()DropOut()

TEACHER

NameAddressTelephoneGetHired() GetPaid()Grade()

UML Simple RELATIONSHIPS

Page 5: Relationships Copyright © 1999 Patrick McDermott UC Berkeley Extension pmcdermott@msn.com Mary Cassatt (1844–1926) Mother and Child against a Green Background

Cardinality

1 to 1

1 to Many

Many to Many

Use Connector (Not Line)

*

**

1 1

1

Of Hottentots, Russians & Systems Analysts

Many:

∞*MN

Page 6: Relationships Copyright © 1999 Patrick McDermott UC Berkeley Extension pmcdermott@msn.com Mary Cassatt (1844–1926) Mother and Child against a Green Background

Association & Relationship

ASSOCIATION: The semantic relationship among two or more classifiers that involves connections among their instances.—Rumbaugh, Reference, p. 152

RELATIONSHIP: A reified semantic connection among model elements. Kinds of relationships include association, generalization, flow, and several kinds of dependency.—Rumbaugh, Reference, p. 411

SO: An association is a kind of relationship, one that isn’t any other kind… —Patrick

Page 7: Relationships Copyright © 1999 Patrick McDermott UC Berkeley Extension pmcdermott@msn.com Mary Cassatt (1844–1926) Mother and Child against a Green Background

1-to-Many• The One side is called

1. “Parent”

2. The Set Owner

3. Root

• The Many side is called1. “Child”

2. A “Member”

3. Branch/Leaf

ShunchōAutumn Excursion during an Abundant Harvest

1770-90

Page 8: Relationships Copyright © 1999 Patrick McDermott UC Berkeley Extension pmcdermott@msn.com Mary Cassatt (1844–1926) Mother and Child against a Green Background

Relationship an Entity?• Relationships have no Attributes• If you need attributes, it’s an Entity• Sometimes called “Junction Class/Record”• Sometimes called “Associative Entity”• ALL entities with 2 owners are associative

– Whether planned or not

Page 9: Relationships Copyright © 1999 Patrick McDermott UC Berkeley Extension pmcdermott@msn.com Mary Cassatt (1844–1926) Mother and Child against a Green Background

Kinds of Relationships

Page 10: Relationships Copyright © 1999 Patrick McDermott UC Berkeley Extension pmcdermott@msn.com Mary Cassatt (1844–1926) Mother and Child against a Green Background

Object Relativity1. Generalization/Specialization

– IS-A2. Aggregation

– IS-PART-OF3. Composition

– IS-MADE-WITH, IS-MADE-FROM

4. Categories– TYPE, KIND-OF, STATUS

5. Sets– IS-COLLECTION-OF, GROUP-OF

Page 11: Relationships Copyright © 1999 Patrick McDermott UC Berkeley Extension pmcdermott@msn.com Mary Cassatt (1844–1926) Mother and Child against a Green Background

Object Examples1. Generalization/Specialization

– A GraduateStudent is a Student

2. Aggregation– A Student is part of a ClassRoster

3. Composition– An Car is made with an Engine

4. Categories– A Sophomore is a type of Student

5. Sets– A Hearing is a collection of Party, Lawyer,

Judge, CourtReporter, CourtRoom

Page 12: Relationships Copyright © 1999 Patrick McDermott UC Berkeley Extension pmcdermott@msn.com Mary Cassatt (1844–1926) Mother and Child against a Green Background

Types of Relationship• IS-A: Generalization, “Inheritance”

• HAS-A: Aggregation• IS-Made-From: Composition

– “A form of aggregation with strong ownership and coincident lifetime of parts by the whole.”– Rumbaugh, Reference, p. 226

– I don’t bother distinguishing from Aggregation

• USES: Association– Default; those that aren’t one of the others

Page 13: Relationships Copyright © 1999 Patrick McDermott UC Berkeley Extension pmcdermott@msn.com Mary Cassatt (1844–1926) Mother and Child against a Green Background

Patrick’s RuleA Relationship is a connection of some

kind between two objects that is significant to the business or system.

Generalizations and aggregations willusually be identified as such, so the genericrelationship is usually not believed to be oneof those. So we will assume an Association until shown otherwise.

The relational model only recognizes Associations, so you won’t be too far off if that’s all you use.

Page 14: Relationships Copyright © 1999 Patrick McDermott UC Berkeley Extension pmcdermott@msn.com Mary Cassatt (1844–1926) Mother and Child against a Green Background

K.I.S.S.

Keep it Simple,Stupid