To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.off-topic.geekOpen lugnet.off-topic.geek in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Off-Topic / Geek / 2354
2353  |  2355
Subject: 
Re: A heirarchical database question
Newsgroups: 
lugnet.off-topic.geek
Date: 
Wed, 15 Nov 2000 06:22:52 GMT
Viewed: 
86 times
  
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:
  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:



Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR