Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What you want is not markup, but tagged unions. It's a real shame SQL and many other languages don't support them.

Also, your example about Spanish names doesn't take into account that nowadays parents can choose the order of family names, and that gay marriage has been legal for 15 years. Which reflects a deeper truth: don't make too strong assumptions about reality, for it may change.



Tagged unions, if I understand what they are, can be done in SQL:

    create table Foo(
      fooId primary key autoincrement, 
      type integer /* tag/discriminant */ );
    create table FooA(fooId primary key,
      /* data specific to FooA */ );
    create table FooB(fooId primary key,
      /* data specific to FooB */ );
They're not quite markup though. Markup has a string/stream with associated records. The number of these records, their kind, and their placement varies, so it can handle ordering issues or multiple similar names or missing name (e.g. missing middle name), or ignore parts of name quite naturally.


That could be an implementation of tagged unions. Without language level support (pattern matching, exhaustiveness checking, etc.) you gain very little from this.


Yes, you can simulate them, but it's painful.


It's not a simulation, it's a data model for reducing the pain for what's really a hard problem - names we call people are not unique, they are colloquial identifiers (HHOS).


Joined tables on the same primary key are a simulation of tagged unions. Proper tagged unions would solve more concisely and with more clarity.


I'd really like to see an RDBMS with built-in support for both inheritance and tagged unions. That would solve 90% of my schema woes.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: