Subject:
|
Re: A heirarchical database question
|
Newsgroups:
|
lugnet.off-topic.geek
|
Date:
|
Wed, 15 Nov 2000 06:22:52 GMT
|
Viewed:
|
86 times
|
| |
![Post a public reply to this message](/news/icon-reply.gif) | |
Jim Hughes wrote:
> Say you had some data that was heirarchical, e.g. a list of Lego Themes:
> What would be the best way to describe it in a DB table? Would this work OK:
> -----------------------------------
> Big table of Themes
>
> theme_parent (varchar)
> theme_name (varchar)
> theme_child(varchar)
What you've basically got there is a linked list. Although this
works well when running through memory, I've found that it's
costly if dealing with SQL queries. Imagine something that's
nested ten levels deep -- you'll have to make 10 individual
SQL queries to find out what the complete path name is. That's
not a big deal for personal use, but in a Web or shared application
it could be a hassle.
What I've done (and I'm sure there are MANY better ways to do it)
is to add another field that actually lists the path, i.e.
theme_path (varchar)
i.e. System/Aquazone/Aquasharks
If you're afraid that the data integrity is going to wane over time,
you could have a script run through the "linked list" nightly and
generate a new theme_path field.
Chris
|
|
Message is in Reply To:
![](/news/x.gif) | | A heirarchical database question
|
| Hi: Here is a question for the DB experts: Say you had some data that was heirarchical, e.g. a list of Lego Themes: -- System ----- Aquazone ---...--- Aquasharks What would be the best way to describe it in a DB table? Would this work OK: ---...--- (...) (24 years ago, 15-Nov-00, to lugnet.off-topic.geek)
|
6 Messages in This Thread: ![A heirarchical database question -Jim Hughes (15-Nov-00 to lugnet.off-topic.geek)](/news/x.gif) ![](/news/246.gif) ![You are here](/news/here.gif)
![](/news/x.gif) ![](/news/268.gif) ![Re: A heirarchical database question -Steve Bliss (15-Nov-00 to lugnet.off-topic.geek)](/news/x.gif)
![](/news/x.gif) ![](/news/68.gif) ![Re: A heirarchical database question -Larry Pieniazek (16-Nov-00 to lugnet.off-topic.geek)](/news/x.gif) ![](/news/46.gif) ![Re: A heirarchical database question -Steve Bliss (17-Nov-00 to lugnet.off-topic.geek)](/news/x.gif) ![](/news/46.gif) ![Re: A heirarchical database question -Larry Pieniazek (18-Nov-00 to lugnet.off-topic.geek)](/news/x.gif)
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|