newbie N-M Self Reference

Posts   
 
    
ChrisMoses
User
Posts: 18
Joined: 22-Feb-2005
# Posted on: 12-Nov-2005 01:52:39   

Hi, I have a basic question about how to create a n-m self reference: I have categories, which have subcategories, etc... I would like to have fields ChildCategories, and PatentCategories,

The database currently has a join table that relates parent categories to child categories.

All I seem to be able to get in the designer are 1-n relationships with the join table. i.e - I could get a collection of the keys to parents or children, but not a collection of the actual parent or child categories.

Anybody have any tips for doing this? I am free to restructure the DB as needed at this point.

Thanks

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 12-Nov-2005 03:52:50   

Is a category able to exist with multiple parents as in a graph or is a tree structure that you are trying to represent. If you are trying to do a graph then I would suggest writting you own code in the user code regions to fill a parent and child collection when the entity is created.

ChrisMoses
User
Posts: 18
Joined: 22-Feb-2005
# Posted on: 16-Nov-2005 04:21:43   

a Category can have multiple parents and children. Presumably, we will have to manually implement the logic to prevent categories from becoming their own parents or categories.

Thanks

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 16-Nov-2005 12:48:46   

An m:n relation with self is not supported, because it's not efficient. You're filtering on the same table, so you can better fetch the related entities using a simple FIeldCompareValue predicte on the FK.

Frans Bouma | Lead developer LLBLGen Pro