> > 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
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
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
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),
> ...
>
> );
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
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
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?