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]...
![Page 1: Relationships II Copyright © 1999 Patrick McDermott UC Berkeley Extension pmcdermott@msn.com Earth’s Interrelated Systems & Climate NASA.](https://reader036.fdocuments.us/reader036/viewer/2022062422/56649f1e5503460f94c35861/html5/thumbnails/1.jpg)
Relationships II
Copyright © 1999 Patrick McDermott
UC BerkeleyExtension
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.](https://reader036.fdocuments.us/reader036/viewer/2022062422/56649f1e5503460f94c35861/html5/thumbnails/2.jpg)
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.](https://reader036.fdocuments.us/reader036/viewer/2022062422/56649f1e5503460f94c35861/html5/thumbnails/3.jpg)
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.](https://reader036.fdocuments.us/reader036/viewer/2022062422/56649f1e5503460f94c35861/html5/thumbnails/4.jpg)
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.](https://reader036.fdocuments.us/reader036/viewer/2022062422/56649f1e5503460f94c35861/html5/thumbnails/5.jpg)
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.](https://reader036.fdocuments.us/reader036/viewer/2022062422/56649f1e5503460f94c35861/html5/thumbnails/6.jpg)
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.](https://reader036.fdocuments.us/reader036/viewer/2022062422/56649f1e5503460f94c35861/html5/thumbnails/7.jpg)
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.](https://reader036.fdocuments.us/reader036/viewer/2022062422/56649f1e5503460f94c35861/html5/thumbnails/8.jpg)
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.](https://reader036.fdocuments.us/reader036/viewer/2022062422/56649f1e5503460f94c35861/html5/thumbnails/9.jpg)
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.](https://reader036.fdocuments.us/reader036/viewer/2022062422/56649f1e5503460f94c35861/html5/thumbnails/10.jpg)
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.](https://reader036.fdocuments.us/reader036/viewer/2022062422/56649f1e5503460f94c35861/html5/thumbnails/11.jpg)
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.](https://reader036.fdocuments.us/reader036/viewer/2022062422/56649f1e5503460f94c35861/html5/thumbnails/12.jpg)
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.](https://reader036.fdocuments.us/reader036/viewer/2022062422/56649f1e5503460f94c35861/html5/thumbnails/13.jpg)
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.](https://reader036.fdocuments.us/reader036/viewer/2022062422/56649f1e5503460f94c35861/html5/thumbnails/14.jpg)
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.](https://reader036.fdocuments.us/reader036/viewer/2022062422/56649f1e5503460f94c35861/html5/thumbnails/15.jpg)
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!