Dealing with hierarchies in a relational database is a pest.
There's Oracle's CONNECT BY PRIOR, and the SQL standard defines
IBM's recursive UNION, but still... wouldn't it be nice if a
hierarchy (or even a full-on graph, like social networks have)
could just be managed cleanly relationally?
This is something Kim and I have been dabbling with. The engine
is called OQGRAPH (OQ for Open Query) now because just graph
caused some symbol conflict hassles. Anyway, following is a brief
demo of how it works.
First, let's insert some data...
mysql> INSERT INTO gstest (origid,destid) VALUES (1,2),(1,3),(2,4);
Get it back out plain...
mysql> SELECT origid AS node, destid AS edge FROM gstest;
+-------------+
| node | edge |
+-------------+
| 1 | 3 |
| 1 | 2 |
| 2 | 4 |
| 3 | NULL |
| 4 | NULL |
+-------------+
(Hey, notice something? the engine …
[Read more]