Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Can Oracle save a tree?
"Ramon F Herrera" <ramon_at_conexus.net> schrieb im Newsbeitrag
news:c9bc36ff.0404271813.1f66aa34_at_posting.google.com...
> The company I work for makes reports for other companies, based
> on geography, states, districts, etc. and the companies can vary
> from a one location shop, to a multinational with thousands of
> branch offices.
>
> Needless to say, the most natural way to store this is in
> a tree data structure. I have already done that at the Java-GUI
> front end, but I was wondering how to do it in the database.
>
> I realize that anything can be flattened to a relational table,
> but I understand that now Oracle has other non-traditional
Well, erh, AFAIK, arenīt tables *very* traditional, since about 30 years maybe :) ? ...
> ways of storing data.
>
> So, is it possible to save a tree in Oracle?
>
You might want to set up a table with a *self reference*:
create table MyTree
(
id number,
parent_id number, --references id
other_column [datatype]...
)
Thatīs about all You need.
Then learn hiw to navigate through it with appropriate SQL
and there You are.
hth, Jan Received on Wed Apr 28 2004 - 04:10:08 CDT