Relationships II Copyright © 1999 Patrick McDermott UC Berkeley Extension [email protected]...
-
Upload
robert-henry -
Category
Documents
-
view
216 -
download
1
Transcript of Relationships II Copyright © 1999 Patrick McDermott UC Berkeley Extension [email protected]...
Relationships II
Copyright © 1999 Patrick McDermott
UC BerkeleyExtension
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
Cardinality
1 to 1
1 to Many
Many to Many
1 1
1
**
*
Multiplicity
1 to 1
1 to Many
Many to Many
0 ..1
0 .. *
1 .. 1
1 .. 1
1 .. *0 .. * O
O
O
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
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
Order to Product
ORDER
PRODUCT
ORDER
PRODUCT
ITEM
QuantityPrice
#
#
#
#
#
#*
*
*
*
Teacher to Student
TEACHER
STUDENT
TEACHER
STUDENT
ENROLLMENT
DateGrade
*
*
*
*
Employee to Department
EMPLOYEE
DEPARTMENT
EMPLOYEE
DEPARTMENT
ASSIGNMENT
DateHours
Complex
For simplicity, reclassify a complex relationship as an entity, related through binary relationships to each of the original entities.
Salesperson Car Customer
SALE
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
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.
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
/
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!
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!