Hi,
I’m trying to create an inherited keyword structure in MySQL, and I’m not sure the best way to proceed. Essentially, I need one table attaching keywords to groups, ie:
create table keywords ([INDENT]varchar(255) keyword,
int(6) groupID[/INDENT]);
where the same keyword can apply to multiple groups and groups can have multiple keywords, as a many-to-many relationship.
Additionally, I need some structure for the groups that allows each group to inherit all of the keywords of its parent group. So far, I’m working with a table like:
create table groups([INDENT]int(6) groupID autoincrement,
varchar(255) groupname,
int(6) parentgroupID,
PRIMARY KEY (groupID)[/INDENT]);
The intent is that if a keyword is changed in a parent group then all of its children, grandchildren, etc. inherit that change.
I’ve tried joining the groups table to itself recursively, but I don’t know how to do that in SQL without hard-coding the number of joins.
Any ideas how to set up that sort of inheritance structure?
Thanks!