Marriage: a brief lesson in database design
March 10, 2010 12:44 PM   Subscribe

A database engineer considers marriage. Starts with heterosexual monogamy and eventually produces a schema that can handle...well, some interesting arrangements.
posted by d. z. wang (52 comments total) 45 users marked this as a favorite
 
Quick note before I finish reading:

During California's depressingly-short-lived moment of marriage equality, the forms read "Party A" and "Party B". Not only is it gender-neutral, it's also quite festive! Party A is at the reception, Party B is on the Party Bus!
posted by muddgirl at 12:49 PM on March 10, 2010 [7 favorites]


Get him to metafilter, stat! There plates of beans that need to be cataloged in databases!
posted by oddman at 12:54 PM on March 10, 2010 [2 favorites]


Makes me think of the private memorandum in which Charles Darwin methodically weighed the cases for and against marrying his future wife, Emma Wedgwood.

Darwin had sound reasons against marrying, sure.
Freedom to go where one liked — choice of Society & little of it. — Conversation of clever men at clubs — Not forced to visit relatives, & to bend in every trifle.
But even sounder reasons for it:
Constant companion, (& friend in old age) who will feel interested in one, — object to be beloved & played with. — —better than a dog anyhow.
posted by cirripede at 12:54 PM on March 10, 2010 [38 favorites]


No provisions to prevent incest? Definitely a database engineer.
posted by XMLicious at 12:57 PM on March 10, 2010 [10 favorites]


Fun read. Not sure I buy that DOMA is sexist since both sexes are affected equally, still thinking about it, but it's an interesting argument.
posted by Blazecock Pileon at 12:57 PM on March 10, 2010 [2 favorites]


Pffft. I implemented my marriage using a distributed keystore. I've got a different wife in each datacentre an none of them know about each other!
posted by GuyZero at 12:58 PM on March 10, 2010 [9 favorites]


Not sure I buy that DOMA is sexist since both sexes are affected equally, still thinking about it, but it's an interesting argument.

In any given situation involving specific individuals, the sexes are not affected equally.
posted by Jaltcoh at 1:02 PM on March 10, 2010 [1 favorite]


XMLicious : "No provisions to prevent incest? Definitely a database engineer."

What does this even mean?
posted by pineapple at 1:10 PM on March 10, 2010


Not sure I buy that DOMA is sexist since both sexes are affected equally...

By weight, as it were, they're equal. Women can't marry women, while men can; men can't marry men, while women can. They're equal prohibitions. It's just that they're...separate. But still equal.
posted by darksasami at 1:19 PM on March 10, 2010 [1 favorite]


Most relational databases allow you to do self joins, yet he wants to prevent it?
posted by blue_beetle at 1:20 PM on March 10, 2010 [1 favorite]


No provisions to prevent incest? Definitely a database engineer."

The database is built to track marriages -- not the legality of them, merely the existence. If incestuous marriage is illegal in a jurisdiction, then any such marriages, legally, do not exist and thus, should never be entered into the marriage tables.

What you need is set of tables to track genetic relationships, and the application should then query those and refuse to insert an invalid marriage. And, of course, the application could look up a religion table and refuse to set anything in the divorce field if you are Roman Catholic. And so forth -- whatever constraints you feel are needed.

But all of that is out of scope. The scope was "a schema to track marriages" and he provided such -- despite the complexity of the seemingly simple question.
posted by eriko at 1:21 PM on March 10, 2010 [3 favorites]


Good God: why illustrate cases one through six? Who would set up tables like this? Nobody.
posted by Ogre Lawless at 1:28 PM on March 10, 2010 [1 favorite]


Ogre Lawless:

Funny you should say that. From the description of case 6:

It's asinine to do it this way. However, there is a good reason why I haven't just skipped schemas schemae schemata One to Six. There are a lot of people in the world who actually think like this. This is their for-real, no-joking conception of "marriage". They do not grasp that men and women are interchangeable, as a result of which homosexual marriages create repulsive integrity problems in their heads. "But if they're both guys, which one is the wife? Does not compute!" How sad.
posted by darksasami at 1:35 PM on March 10, 2010 [1 favorite]


Good God: why illustrate cases one through six? Who would set up tables like this? Nobody.

You are a very optimistic person.
posted by kmz at 1:37 PM on March 10, 2010 [22 favorites]


And it's not just bigotry that would lead to somebody using schemas like those either. Just plain old laziness or ignorance of database principles would suffice.
posted by kmz at 1:39 PM on March 10, 2010 [1 favorite]


Who would set up tables like this? Nobody.

I guess nobody has ever handed you an amateur-designed access db to clean up.
posted by empath at 1:46 PM on March 10, 2010 [3 favorites]


After reading the FPP text, I was shocked to find that the link wasn't to XKCD.
posted by aaronetc at 1:56 PM on March 10, 2010 [2 favorites]


My db experience is rusty, but I can think of something considerably worse.

`People`
-`id`
-`HusbandName` (NULL if single female)
-`HusbandBirthdate` (NULL if single female)
-`WifeName` (NULL if single male)
-`WifeBirthdate` (NULL if single male)
-`MarriedDate`

Then when there is a marriage or divorce (assuming patriarchal asshole-ishness goes hand in hand with this level of screwed up) you add or remove the wife entry from the line, add or Null the married date. Note that this schema would probably destroy the maiden identity of any woman in the system.

I'm desperately hoping no one that dumb is ever put in charge of laying out a db, but I suspect otherwise. There should be a dba's Murphy's law somewhere that says "The schema can always be worse".
posted by BrotherCaine at 2:00 PM on March 10, 2010 [2 favorites]


IANAHistorian, but I think the Romans actually had a problem like this, since women were named according to their descent (wiki). I remember the Wikipedia write-up for some Roman woman saying that historians lost track of her, and that the last possible mention might actually refer to some relative of this person who would have the same name.
posted by d. z. wang at 2:19 PM on March 10, 2010


This has made my day.

SRSLY. I do this sort of thing all day, and seeing someone make such an obvious, but lateral, move with it has filled me with hope for our glorious technical future.
posted by clvrmnky at 2:20 PM on March 10, 2010


Or there's my favorite solution, which is to let any frigging person make a private contract with any other frigging person and don't frigging track it all in some database somewhere, and definitely don't frigging require permission from some frigging bureaucrat who has nothing to do with the arrangement in the first place.
posted by The Winsome Parker Lewis at 2:23 PM on March 10, 2010 [3 favorites]


The reason to track in a database is so that the right implicit in the arrangement are quickly available. For example when visiting in a hospital that restricts patient access.
posted by BrotherCaine at 2:38 PM on March 10, 2010 [2 favorites]


Or there's my favorite solution, which is to let any frigging person make a private contract with any other frigging person and don't frigging track it all in some database somewhere, and definitely don't frigging require permission from some frigging bureaucrat who has nothing to do with the arrangement in the first place.

You may wanna narrow down "private contract" to just "marriage", because I can see all kinds of ways that would go wrong (it's one of those things that assumes everyone is a moral actor), but otherwise yeah. Marriage is a pretty archaic idea anyway.
posted by DecemberBoy at 2:39 PM on March 10, 2010


(For one thing, remember that a corporation, for the purposes of law, is a person)
posted by DecemberBoy at 2:40 PM on March 10, 2010


In any given situation involving specific individuals, the sexes are not affected equally.

I can see how that would bolster the argument, thanks.
posted by Blazecock Pileon at 2:47 PM on March 10, 2010


(For one thing, remember that a corporation, for the purposes of law, is a person)

So if I have an Employment Contract (and apparently, even 'at will' employment often uses a contract these days), everyone at my office can visit me in the hospital while my less-than-closest blood relatives can't. I, for one, think that'd be cool.
posted by oneswellfoop at 2:55 PM on March 10, 2010


This is what we call a suppressed premise.

The whole thing falls apart if you reject the "men and women are interchangeable" premise. Sneaking that in at the end there is, well, sneaky. It's not a premise which has anything whatsoever to do with the logic of the situation--whether or not men and women are interchangeable is not a question one can answer using logic alone--making the whole exercise entirely misleading. The only way his conclusion is cleaner is if you smuggle in a wildly controversial assumption.

I'm just sayin'. You want to make a logical point, you should try to do the logic right.
posted by valkyryn at 3:06 PM on March 10, 2010


Or there's my favorite solution, which is to let any frigging person make a private contract with any other frigging person

Some of the legal benefits of marriage are not achievable by contract, e.g., spousal privilege.
posted by DevilsAdvocate at 3:26 PM on March 10, 2010 [1 favorite]


How nerdy am I that my first thought was "Huh, finally a real-world application for Neo4j!"
posted by hincandenza at 3:32 PM on March 10, 2010


...which is a real shame. Arguably a symptom of the marriage morass, and not the disease.
posted by The Winsome Parker Lewis at 3:33 PM on March 10, 2010


(replying to DevilsAdvocate, sorry hincandeza)
posted by The Winsome Parker Lewis at 3:33 PM on March 10, 2010


No, you're right- if I was married, I'd probably be less nerdy.
posted by hincandenza at 3:38 PM on March 10, 2010 [2 favorites]


GuyZero: by using a distributed keystore, especially if it's a schemaless hash db like MongoDB or CouchDB, you're simply using hierarchy to replicate patriarchal structures of power. How are you ever going make transactions you can back out of, or handle any kind of major migration?

How could you be so blind as to not know what Voldemort does to good marriages?

Sigh.
posted by honest knave at 4:12 PM on March 10, 2010 [2 favorites]


How timely -- thanks for the link! I find it particularly amusing, interesting and germane as a life-long self-identified 'gay male' who has just become officially 'engaged to be married' to my college sweetheart, a 'straight woman' with whom I fell in love at first sight 30 years ago.

Neither of us has any idea how it will actually play out, in part because we currently reside 6000 miles away from one another on different continents, haven't seen each other in 15 years, and are both nearly unemployed, and poor as church mice.

All we know for sure is that we've been in love and heartbroken to be separated all these years and both want to finish out our years together, as helpmates, companions, and lovers. We're determined to make it happen while we are both still fortunate enough to not be dead yet, but damned if we know how to proceed at this point. First thing I guess is get a job.

(Also, I spent many years as a database/UI developer, so it was funny and fun to read from that aspect.)
posted by trip and a half at 4:33 PM on March 10, 2010 [6 favorites]


How are you ever going make transactions you can back out of, or handle any kind of major migration?

DB integrity constrains are for weak programmers. I ensure these things by SHEER FORCE OF WILL.
posted by GuyZero at 4:38 PM on March 10, 2010 [2 favorites]


NoSQL to the rescue. CouchDB documents!

Marriage database example document:

{
  "_id": "marriage_id1234567890",
  "_rev": "1234567890",
  "people": [
    "PersonA": {
      "gender": "male"
      "sex": "male"
      "other_info": "whatever" },
    "PersonB": {
      "gender": "female"
      "sex": "intersex"
      "other_info": "what" }],
  "marriage_date": "01/01/2010",
  "divorce_date": "01/01/2010",
  "other_marriage_info": "what"
}

(then you spend 2 hours building a map-reduce function in javascript to query by name so you can find all marriages by PersonA while tearing your hair out
OR
build a separate database to store by people and marraige IDs while hoping to god the two databases don't get out of sync and rebuild the people db from the first db if they do)

posted by amuseDetachment at 4:41 PM on March 10, 2010 [4 favorites]


honest knave: GuyZero: by using a distributed keystore, especially if it's a schemaless hash db like MongoDB or CouchDB
See, the DBE in the original post accounts for non-standard genders and sexual identities, and thus doesn't have the issue of his data store being shemale-less.
posted by hincandenza at 4:41 PM on March 10, 2010 [1 favorite]




I do like the neologism "antihomonuptual." If he had invented nothing else in that column, it would still have been full of win.
posted by djfiander at 5:22 PM on March 10, 2010 [4 favorites]


then you spend 2 hours building a map-reduce function in javascript to query by name so you can find all marriages by PersonA while tearing your hair out

You could also use something like MongoDB (document database with indexes!).
posted by ryoshu at 5:57 PM on March 10, 2010


Schemas 2-5 allow polyandry. I wonder if that is by design.
posted by autopilot at 6:12 PM on March 10, 2010


Polyamory is wrong, by the way.

You can be either multiamorous or polyphilic.

Polyamory is an ill conceived collision of Greek and Latin.

Polyandry is OK, too, as long as it is all boys.
posted by poe at 7:35 PM on March 10, 2010 [3 favorites]


then you spend 2 hours building a map-reduce function in javascript to query by name so you can find all marriages by PersonA while tearing your hair out

How hard can it be? I mean—everything is a fold, even maps.
posted by kenko at 8:03 PM on March 10, 2010 [1 favorite]


This gave me a smile. I enjoyed the author walking through the stupid cases, it lets us look into his thought process.
posted by captaincrouton at 9:24 PM on March 10, 2010


NoSQL to the rescue.

Oh how I despise that term. Yay! Key-value pairs with domain level schemas! It's... just like everything we've been using for years!

(I say this as someone who will soon be open sourcing an incredibly heavily used product that could reasonably be called part of the "NoSql Movement" if I didn't hate rebranding of old ideas and attempting to apply them to everything. I'm looking at you, web services SOA "the cloud")
posted by flaterik at 9:30 PM on March 10, 2010 [2 favorites]


Yeah the idea's not new, but what the hell else are you going to call it? "Key-value pairs" isn't particularly correct, as modern implementations are massively distributed and heavily emphasize eventual consistency. This movement needs a practical name that is fast and easy, NoSQL fits the bill and is fairly descriptive. Voldemort and Cassandra are not Memcachedb, to describe them as "key-value-pair databases" isn't precise. If you have a better accurate name than isn't ten syllables long, I'd be happy to use it.
posted by amuseDetachment at 10:43 PM on March 10, 2010 [1 favorite]


Wouldn't it be a lot easier to have a database of the relationships, with people as indexes, rather than a database of people with relationships as indexes? Relationships can be assigned a name and/or description, given reflectivity where needed (eg X is the son of Y implies that Y is the father of X), given date/time data and notes assigned to those, etc.
posted by aeschenkarnos at 2:04 AM on March 11, 2010


Ogre Lawless: Good God: why illustrate cases one through six? Who would set up tables like this? Nobody.

... except that Case 1 (husbands and wives interconnected only through redundant information) is exactly what Outlook forces me to do.
posted by IAmBroom at 7:04 AM on March 11, 2010 [1 favorite]


No, really, you can have Greek AND Latin. That's the whole point.

internet fraud detective squad, station number 9, you magnificent bastard. I'd buy you a month of Metafilter, except...
posted by IAmBroom at 7:09 AM on March 11, 2010


"(For one thing, remember that a corporation, for the purposes of law, is a person)"

In this case, corporations have more rights than individuals, as they can form mergers of any kind or number they want, jointly or severally (i.e., intransitive as discussed in the article). Humans can have babies, you say? Well, any reasonable contract provides in advance for the terms of separation. Divorce is traumatic for children, regardless of how many parties are involved (and indeed, if one of four partners is leaving, having three remaining parents might provide more support).

Personally, I'm thinking of coming out as panamorous. Err, panphilic. I love everyone.
posted by Eideteker at 7:50 AM on March 11, 2010


That was truly geeky and wonderful, d. z. wang. Thanks.
posted by cowbellemoo at 12:41 PM on March 11, 2010


I hear you, amuseD. My problem is more with people that are evangelizing it as the new solution for everything. I've heard advocation of getting RID of our SQL databases....

NoSql is basically smart caching. I'll call it that ;)
posted by flaterik at 2:19 PM on March 11, 2010


« Older ...of fashion   |   The Novice Effect Newer »


This thread has been archived and is closed to new comments