Top Banner
Relationships II Copyright © 1999 Patrick McDermott UC Berkeley Extension [email protected] Earth’s Interrelated Systems & Climate NASA
15

Relationships II Copyright © 1999 Patrick McDermott UC Berkeley Extension [email protected] Earth’s Interrelated Systems & Climate NASA.

Jan 04, 2016

Download

Documents

Robert Henry
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Relationships II Copyright © 1999 Patrick McDermott UC Berkeley Extension pmcdermott@msn.com Earth’s Interrelated Systems & Climate NASA.

Relationships II

Copyright © 1999 Patrick McDermott

UC BerkeleyExtension

[email protected]

Earth’s Interrelated Systems & Climate

NASA

Page 2: Relationships II Copyright © 1999 Patrick McDermott UC Berkeley Extension pmcdermott@msn.com Earth’s Interrelated Systems & Climate NASA.

Optionality

• Is it Mandatory or Optional?• A Business Rule

– But practicalities, too

o Is zero a number???

• Programmers: 0, 1, • Hottentots: 1, 2, Many• Analysts: 0, 1, Many

Page 3: Relationships II Copyright © 1999 Patrick McDermott UC Berkeley Extension pmcdermott@msn.com Earth’s Interrelated Systems & Climate NASA.

Cardinality

1 to 1

1 to Many

Many to Many

1 1

1

**

*

Page 4: Relationships II Copyright © 1999 Patrick McDermott UC Berkeley Extension pmcdermott@msn.com Earth’s Interrelated Systems & Climate NASA.

Multiplicity

1 to 1

1 to Many

Many to Many

0 ..1

0 .. *

1 .. 1

1 .. 1

1 .. *0 .. * O

O

O

Page 5: Relationships II Copyright © 1999 Patrick McDermott UC Berkeley Extension pmcdermott@msn.com Earth’s Interrelated Systems & Climate NASA.

Multiples• 2 Teachers, 1 ClassSection• 2 Courses, 1 ClassSection• Employee with 2 Bosses

• Choose the main one• Define one as ‘first’

– Primary contact

• Denormal 1, 2• New table

Page 6: Relationships II Copyright © 1999 Patrick McDermott UC Berkeley Extension pmcdermott@msn.com Earth’s Interrelated Systems & Climate NASA.

Break M2m

1 Stick a Box in the Middle• “Intersection Table”• “Junction table”

2 Flip the Asterisks (Arrows) In3 Migrate the Keys4 Find a Name5 See if it’s already there

6 Add attributes of the Junction

Page 7: Relationships II Copyright © 1999 Patrick McDermott UC Berkeley Extension pmcdermott@msn.com Earth’s Interrelated Systems & Climate NASA.

Order to Product

ORDER

PRODUCT

ORDER

PRODUCT

ITEM

QuantityPrice

#

#

#

#

#

#*

*

*

*

Page 8: Relationships II Copyright © 1999 Patrick McDermott UC Berkeley Extension pmcdermott@msn.com Earth’s Interrelated Systems & Climate NASA.

Teacher to Student

TEACHER

STUDENT

TEACHER

STUDENT

ENROLLMENT

DateGrade

*

*

*

*

Page 9: Relationships II Copyright © 1999 Patrick McDermott UC Berkeley Extension pmcdermott@msn.com Earth’s Interrelated Systems & Climate NASA.

Employee to Department

EMPLOYEE

DEPARTMENT

EMPLOYEE

DEPARTMENT

ASSIGNMENT

DateHours

Page 10: Relationships II Copyright © 1999 Patrick McDermott UC Berkeley Extension pmcdermott@msn.com Earth’s Interrelated Systems & Climate NASA.

Complex

For simplicity, reclassify a complex relationship as an entity, related through binary relationships to each of the original entities.

Salesperson Car Customer

SALE

Page 11: Relationships II Copyright © 1999 Patrick McDermott UC Berkeley Extension pmcdermott@msn.com Earth’s Interrelated Systems & Climate NASA.

Y 1-2-1?

1. Faster queries if often need a few

2. Isolate null, unknown values

3. Ez2 restrict access

4. Separate BLOBs

Stuff More Stuff1 1

Page 12: Relationships II Copyright © 1999 Patrick McDermott UC Berkeley Extension pmcdermott@msn.com Earth’s Interrelated Systems & Climate NASA.

BOM

• Bill-Of-Materials– A Part is made up of Parts– Manufactures– Hamburger

• A BOM Explodes and Implodes• Be careful if traveling!

– “Explode the BOM” could get you in trouble– If you see your friend Jack, don’t say “Hi”

• Recursive

PartPart

Part

Part

Part

Part.

Page 13: Relationships II Copyright © 1999 Patrick McDermott UC Berkeley Extension pmcdermott@msn.com Earth’s Interrelated Systems & Climate NASA.

Book Example• M2M• Title

– Can’t copyright ©• Publisher• Edition

• Who’s asking?– Reader wants any copy of the “Book”– Buyer wants cheapest copy of the “Book”– Shakespeare: Good/Bad Quartos, 1st-4th Folios

Adelaide ClaxtonWonderland

/

Page 14: Relationships II Copyright © 1999 Patrick McDermott UC Berkeley Extension pmcdermott@msn.com Earth’s Interrelated Systems & Climate NASA.

Compromise

• Who Cares?• How many are there?• Is it Worth It?• What do you buy by accommodating it?• What do you lose by not accommodating it?• Economics in Action!

Page 15: Relationships II Copyright © 1999 Patrick McDermott UC Berkeley Extension pmcdermott@msn.com Earth’s Interrelated Systems & Climate NASA.

Hierarchies & Trees

Powers of 2: G2

• For Genealogy, only 1 side– Patrilineal or Matrilineal

• 500 years ago– You had 1,000,000 forebears?!?

Ancestral Village• Who are you related to?• Everyone in the Village!