I'm passing along an article I saw at DevX.
-David

"Represent hierarchical data structures in a relational database."
http://www.vbpj.com/upload/free/features/vbpj/2001/07jul01/sqlpro0107/rein01  
07/rein-1.asp

Here are the first few paragraphs:

"A tree data structure, like a corporate organization chart, shows the 
relationships between various pieces of information. How you use the data 
determines the method you use for storing it. I'll demonstrate a number of 
techniques and show you how to use them in different situations."

"You can represent trees in a relational database in one of three ways: with 
the one-to-one parent-child method, the one-to-many parent-child method, or 
what Joe Celko calls the nest set method (see Resources). First, with the 
one-to-one method, you can store the data for each node in a single database 
table. You save the information about the relationships between nodes in the 
same table as the information contained in the node. Second, with the one-to  
-many method, you use two tables: one with the node information and a second 
with the relationship information. When you need to store an exact 
representation of the entire tree, you can use a third method, the nest set 
method, which also involves two tables. The first table contains the node 
information, and the second identifies each node and references the node 
information table. The second table doesn't define any relationships-the 
relationships are derived from the identifiers of each node."

"I'll use a corporate organization chart to demonstrate each technique. An org 
chart represents a company's chain of command
graphically. A typical chart shows the president or CEO at the top and the 
field workers at the bottom."


Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to