From: Martijn Tonies Date: October 19 2004 11:41am Subject: Re: Ask for help on a mysql problem List-Archive: http://lists.mysql.com/mysql/174452 Message-Id: <02d901c4b5d0$a1691520$0a02a8c0@martijn> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Egor, others, > It's really clear what you want. Please specify. > > If what you basicaly want is just a tree structure, then it's done like that: > > > CREATE TABLE something ( > id INT AUTO_INCREMENT PRIMARY KEY NOT NULL, > parent INT NOT NULL, > data1 CHAR(255), > data2 CHAR(255), > ... > > ); > > Then you can specify the parent node id for each record in database. > This is how tree-like structures are stored in SQL. Hope that helps. That is ONE way to store a tree structure :-) Another would be: ITEMS (ItemID INT AUTO_INCREMENT PRIMARY KEY NOT NULL, other stuff) ITEM_PARENT (ItemID int, ParentID int primary key (ItemID, ParentID) ) I prefer the latter. With regards, Martijn Tonies Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL Server. Upscene Productions http://www.upscene.com