Gay Marriage from a Database Engineering Perspective

Gay Marriage from a Database Engineering Perspective

This talk is adapted from qntm.org/gay - an essay about how not to write homophobic databases, and why politicians might be dragging their feet.

248ff8e8c560fbd557fd1c52634a0543?s=128

Liz Howard

March 15, 2013
Tweet

Transcript

  1. Gay Marriage! From a database engineering perspective @lizTheDeveloper Adapted from

    an essay by Sam Hughes @ qntm.org/gay Friday, March 15, 13
  2. Friday, March 15, 13

  3. What is Marriage? Friday, March 15, 13

  4. Love? Friday, March 15, 13

  5. Childbearing? Friday, March 15, 13

  6. Sociological construct designed to make agricultural societies run smoother? Friday,

    March 15, 13
  7. A Relationship Friday, March 15, 13

  8. A Relationship... • Recognized by the state Friday, March 15,

    13
  9. A Relationship... • Recognized by the state • That affords

    certain legal rights Friday, March 15, 13
  10. A Relationship... • Recognized by the state • That affords

    certain legal rights • Defines common property Friday, March 15, 13
  11. A Relationship... • Recognized by the state • That affords

    certain legal rights • Defines common property • Automagically determines parentage of children created while in the relationship. Friday, March 15, 13
  12. That’s all we track. Friday, March 15, 13

  13. That’s all we track. From a database engineering perspective. Friday,

    March 15, 13
  14. Everything else.... Friday, March 15, 13

  15. Everything else.... is beyond the scope of this talk. Friday,

    March 15, 13
  16. How to store a relationship? Friday, March 15, 13

  17. Quick Vocabulary • Entities • Relationship • Metadata • Key

    Friday, March 15, 13
  18. Foreign Keys • Every entity has an ID • Other

    entities reference that ID Friday, March 15, 13
  19. “Good Enough for Government Work” `males` - `id` - `forename`

    - `surname` - `birthdate` - `wife_id` (foreign key references column `females`.`id`, may be NULL if male is unmarried) `females` - `id` - `forename` - `surname` - `birthdate` - `husband_id` (foreign key references column `males`.`id`, may be NULL if female is unmarried) Friday, March 15, 13
  20. Problem? • Bad Referential Integrity • Relationships can be one-way

    • Duplicates data • No metadata about relationship • Lots of other things Friday, March 15, 13
  21. Sexist Database Design `males` - `id` - `forename` - `surname`

    - `birthdate` - `wife_id` (unique foreign key references column `females`.`id`, may be NULL if male is unmarried) `females` - `id` - `forename` - `surname` - `birthdate` Friday, March 15, 13
  22. Friday, March 15, 13

  23. Serious problems • Mind-bogglingly sexist • But slightly better, from

    an engineering perspective (shockingly.) • Still have a lack of metadata Friday, March 15, 13
  24. Sexism with Metadata `males` - `id` - `forename` - `surname`

    - `birthdate` - `wife_id` (foreign key references column `females`.`id`, may be NULL if male is unmarried) - `marriage_date` (may be NULL if male is unmarried) - `divorce_date` (may be NULL if male is unmarried or married but not yet divorced) `females` - `id` - `forename` - `surname` - `birthdate` Friday, March 15, 13
  25. Friday, March 15, 13

  26. Problem? • Still sexist! • Also, men can only be

    married/divorced once. • “Flat” data presents these problems. Friday, March 15, 13
  27. So... what do we do? Friday, March 15, 13

  28. Relationship Tables `males` - `id` - `forename` - `surname` -

    `birthdate` `females` - `id` - `forename` - `surname` - `birthdate` `marriages` - `id` - `husband_id` (foreign key references column `males`.`id`) - `wife_id` (foreign key references column `females`.`id`) - `marriage_date` - `divorce_date` (NULL if marriage not ended) Friday, March 15, 13
  29. Storing a relationship makes sense. Friday, March 15, 13

  30. But we still have problems • Still sexist • Separating

    genders doesn’t make sense. Friday, March 15, 13
  31. If two entities are equal (like men and women) then

    there is no reason to stratify them. Friday, March 15, 13
  32. We are all humans. `humans` - `id` - `forename` -

    `surname` - `birthdate` - `sex` ("male" or "female") `marriages` - `id` - `partner_1_id` (foreign key references column `humans`.`id`) - `partner_2_id` (foreign key references column `humans`.`id`) - `marriage_date` - `divorce_date` (NULL if marriage not ended) Friday, March 15, 13
  33. Problems? • Unary marriages are now possible - you can

    marry yourself. • The “sex” column is more limiting than it seems. Friday, March 15, 13
  34. “There’s gonna be a lot more guys with makeup this

    millennium” - Eddie Izzard `humans` - `id` - `forename` - `surname` - `birthdate` - `sex_id` (foreign key references column `sexes`) `marriages` - `id` - `partner_1_id` (foreign key references column `humans`.`id`) - `partner_2_id` (foreign key references column `humans`.`id`) - `marriage_date` - `divorce_date` (NULL if marriage not ended) `sexes` - `id` - `string` Friday, March 15, 13
  35. What is Sex/Gender? Friday, March 15, 13

  36. `humans` - `id` - `forename` - `surname` - `birthdate` -

    `sex_id` (foreign key references column `sexes`) - `gender_id` (foreign key references column `genders`) `marriages` - `id` - `partner_1_id` (foreign key references column `humans`.`id`) - `partner_2_id` (foreign key references column `humans`.`id`) - `marriage_date` - `divorce_date` (NULL if marriage not ended) `sexes` - `id` - `string` `genders` - `id` - `string` Gender is a Spectrum Friday, March 15, 13
  37. Existential Crisis mode! Friday, March 15, 13

  38. Let’s just forget about it. `humans` - `id` - `forename`

    - `surname` - `birthdate` `marriages` - `id` - `partner_1_id` (foreign key references column `humans`.`id`) - `partner_2_id` (foreign key references column `humans`.`id`) - `marriage_date` - `divorce_date` (NULL if marriage not ended) Friday, March 15, 13
  39. We’re done, right? Please oh please let us be done.

    Friday, March 15, 13
  40. Friday, March 15, 13

  41. Relationships are discrete entities, but so are marriage partners. Friday,

    March 15, 13
  42. Let’s take it slowly. `humans` - `id` - `forename` -

    `surname` - `birthdate` `marriages` - `id` - `marriage_date` - `divorce_date` (NULL if marriage not ended) `marriage_partners` - `id` - `human_id` (foreign key references column `humans`.`id`) - `marriage_id` (foreign key references column `marriages`.`id`) Friday, March 15, 13
  43. Problems? • What if a human joins the marriage after

    it begins? From a database engineering perspective. Friday, March 15, 13
  44. It’s all about metadata `humans` - `id` - `forename` -

    `surname` - `birthdate` `marriages` - `id` `marriage_partners` - `id` - `human_id` (foreign key references column `humans`.`id`) - `marriage_id` (foreign key references column `marriages`.`id`) - `marriage_date` - `divorce_date` (NULL if still in marriage) Friday, March 15, 13
  45. Friday, March 15, 13

  46. Marriage == Graph Theory Friday, March 15, 13

  47. Intransitive Marriage Friday, March 15, 13

  48. Non-communicative Marriage Friday, March 15, 13

  49. Architecture Astronauts never get married Friday, March 15, 13