That is a very cool article. It is Somewhat like storing a linked list. here is some ascii art that might help :)
|------| \/ | +=======+ | | affs | | +-------+ | |pk |--| |info | |fk | +=======+ (pk = primary key fk = foreign key) So the first item has nothing in the foreign key, and all others have their foreign key set to their parents primary key. for example (mssql server) -- adding a new affiliate INSERT INTO affs ( info, fk )values( 'this is a new aff', (SELECT pk FROM affs WHERE info = 'parent affiliate' ) then go get all the affiliates for one affiliates you could do SELECT * FROM affs WHERE fk = (SELECT pk FROM affs WHERE info = 'parent affiliate') Hope that helps a bit, Rob -----Original Message----- From: Mahmut Basaran [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 08, 2003 8:24 PM To: CF-Talk Subject: parent - child relations Hi All, I need some advices (and sample codes if possible) about how to implement a parent child style database. I read the articles at sql team http://www.sqlteam.com/item.asp?ItemID=8866 Anyone has a better and/or easier solution for nested trees ? By the way I'm going to use it to calculate sales totals of affiliates where an affiliate can have their own sub affiliates, and a sub affiliate can have its own ones too etc... Any advise is greatly appreciated, Mahmut Basaran ~~oO Measure Twice Cut Once Oo~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4