On Wed, Dec 13, 2000 at 11:38:18AM -0800, Stuart Statman wrote: [ . . . ] > I would suggest, instead, to create a table that represents your hierarchy > without adding columns. For example : > > create table Category ( > CategoryID int4 not null primary key, > ParentCategoryID int4 not null REFERENCES Category (CategoryID), > CategoryName varchar(100) > ); > > Add a CategoryID with an FK reference to this table, and your work is done. > > Then adding, inserting, removing, or moving layers in the hierarchy becomes > quite simple. This also preserves hierarchical integrity, where subcategory > a of subcategory b will also remain a subcategory of category c if > subcategory b is a subcategory of subcategory c, where I'm not sure your > model will preserve or guarantee that. (Does that sentence deserve a prize?) Cool. That looks like my solution. I had actually seen it someplace before, but didn't make the connection with my problem. Ta, Frank
- Re: [SQL] How to represent a tree-structu... clayton cottingham
- Re: [SQL] How to represent a tree-structure in a r... Mathijs Brands
- RE: [SQL] How to represent a tree-structure i... Stuart Statman
- Re: [SQL] How to represent a tree-structu... Mathijs Brands
- Re: [SQL] How to represent a tree-structure in a r... miguel sofer
- Re: [SQL] How to represent a tree-structure i... Alvar Freude
- Re: [SQL] How to represent a tree-structu... Alvar Freude
- Re: [SQL] How to represent a tree-structu... miguel sofer
- Re: [SQL] How to represent a tree-str... Alvar Freude
- RE: [SQL] How to represent a tree-structure in a r... Stuart Statman
- Re: [SQL] How to represent a tree-structure i... Frank Joerdens
- Re: [SQL] How to represent a tree-structu... Josh Berkus
- RE: [SQL] How to represent a tree-str... Stuart Statman
- Re: [SQL] How to represent a tree... Josh Berkus
- Re: [SQL] How to represent a... Mathijs Brands
- Re: [SQL] How to represe... clayton cottingham
- RE: [SQL] How to represent a... Opec Kemp \( Ozemail \)
- Re: [SQL] How to represent a... Tulassay Zsolt
- Re: [SQL] How to represe... Tulassay Zsolt
- Re: [SQL] How to represent a tree-str... Robert B. Easter
- Re: [SQL] How to represent a tree-structure i... Ron Peterson