Encoding materialized path in an atomic value.

From: David Cressey <david.cressey_at_earthlink.net>
Date: Fri, 23 Sep 2005 20:24:42 GMT
Message-ID: <ewZYe.2909$vw6.917_at_newsread1.news.atl.earthlink.net>



The recent discussion in another thread about encoding an entire materialized path in a single value started me down the following path.

It's common practice on genealogy websites to adopt a numeric encoding method for family trees of ancestors of a given person. The tree of a person's descendants follow a pattern familiar to us as "parent child relationships".

But genealogists sometimes work the family tree the other way. That is, you have two parents, and each of your parents has two parents giving you four grandparents, eight greatgrandparents, this process is limited, but we can ignore that for now.

Anyway, a common encoding technique for ancestor's is to assign a number for each ancestor, according to a binary pattern, with one for a father and zero for a mother.

Thus your ancestor number 23 is as follows: writing the number in binary, but showing the bits backwards (LSB first): 11101

This means that ancestor 23 is you father's father's father's mother's father.

This only works for binary trees, but the same technique can be generalized, or a technique can be used for reducing arbitrary trees to binary tree equivalents.

23 is, I think we will all agree "atomic" or "simple" enough so that it can be stored in a single value. This case is independent of whether or not one agrees that only atomic values can be stored in a relational table. Received on Fri Sep 23 2005 - 22:24:42 CEST

Original text of this message