Uniquely adding keywords to a "cross-reference table"
Posted: Fri Oct 11, 2013 2:02 pm
[This post is an archive from old SQL Yoga forums]
In my keywords "cross-reference table":
The left and right tables are primary keys and therefore unique, but i can't figure a fast way to add a keyword once without checking first to see what keywords are already associated with a handler which is slow - is there a fast way to ensure that the link table can only have unique combinations of "handler_id" and "keyword_id" so i can;t have more than one "array" keyword linked to a given handler for instance?
In my keywords "cross-reference table":
Code: Select all
tblrelation_createObject "handler to keywords"
tblrelation_set "handler to keywords", "type", "many-to-many"
tblrelation_set "handler to keywords", "left table", "handler"
tblrelation_set "handler to keywords", "left table key", "id"
tblrelation_set "handler to keywords", "cross-reference table", "handler_keywords"
tblrelation_set "handler to keywords", "cross-reference table key for left table", "handler_id"
tblrelation_set "handler to keywords", "cross-reference table key for right table", "keyword_id"
tblrelation_set "handler to keywords", "right table", "keywords"
tblrelation_set "handler to keywords", "right table key", "id"
tblrelation_set "handler to keywords", "order by", "handler.name"