Re: Ask for help on a mysql problem

2004-10-19 Thread Martijn Tonies
> > 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. > > The latter is n

Re: Ask for help on a mysql problem

2004-10-19 Thread Harald Fuchs
In article <[EMAIL PROTECTED]>, "Martijn Tonies" <[EMAIL PROTECTED]> writes: > 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

Re: Ask for help on a mysql problem

2004-10-19 Thread Martijn Tonies
Hello, > The only difference is that you have moved parent outside main table. > No benefits at all. You have to create two records I two tables instead of > one. You have to make joins to see what is the parent of particular child. > I am strongly against this. Why? 1) relational theory clearly

Re: Ask for help on a mysql problem

2004-10-19 Thread Martijn Tonies
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), > ... > > );

Re: Ask for help on a mysql problem

2004-10-19 Thread Egor Egorov
Teng Wang <[EMAIL PROTECTED]> wrote: 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

Re: Ask for help on a mysql problem

2004-10-15 Thread Diona Kidd
Teng, how is this different than a foreign key? On Oct 14, 2004, at 11:27 PM, Teng Wang wrote: I wanna setup a tree structure. Each node in this tree is a table. Each table has a "link" field. For each record, the data in this field is a pointer to another table or null. I read mysql manual but don

Ask for help on a mysql problem

2004-10-14 Thread Teng Wang
I wanna setup a tree structure. Each node in this tree is a table. Each table has a "link" field. For each record, the data in this field is a pointer to another table or null. I read mysql manual but don't find any clues that SQL supports such a "link" field. Does anyone has an idea about that?