On Mon, Jan 19, 2004 at 06:52:41AM +0800, John Scott wrote:
>
> Hello folks,
>
> I am thinking of to create a database with a tree structure.
> ...
Hi,
A very interesting way is described in the excellent book "Advanced
SQL" by Joe Celko: basically, a tree can be viewed as a set of
(sub-)sets. The root is the bigger set because it contains all the
others.
Imagine you have a tree of person names:
Foo
|
---- ----
| |
aaa bbb
|
ccc
A node is a record of the following table :
CREATE TABLE Person (
name char(3),
left integer,
right integer
);
And the above tree can be described with these records :
NAME LEFT RIGHT
Foo 1 8
aaa 2 5
ccc 3 4
bbb 6 7
I hope this example will give you the general idea. I'm sure you
can find much more information about this method on Google.
Regards,
Stephane.
--
<[EMAIL PROTECTED]> - <[EMAIL PROTECTED]> (\(__)/)
FreeBSD Francophone : www.freebsd-fr.org `(QQ)'
Club Unix/Log. libres Cosne/Loire : www.cosnix.org ) (
(o o)
% ATTAC : www.attac.org `--'
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]