Here is what I attempt to acheive :
I have one table fabric
containing fabrics to build a product. When the administrator record a new fabric he can define if this fabric can be selected with another one (for compatibility of materials).
This exclusion relationship is commutative. If X doesn't go with Y, it means that Y can't go with X.
To implement that I created a table fabric_exclusion
with two fields (id_fabric1
and id_fabric2
) forming a primary key.
But how can I have CRUD operations working with this underlaying logic (id_fabric1=X|id_fabric2=Y) = (id_fabric1=Y|id_fabric2=X)
?
UPDATE: Here is what I already tried :
CREATE TABLE IF NOT EXISTS `PREFIX_fabric_exclusion` (
`id_fabric1` INT(10) NOT NULL,
`id_fabric2` INT(10) NOT NULL,
CONSTRAINT `ids` UNIQUE (`id_fabric1`, `id_fabric2`),
PRIMARY KEY `ids`
) ENGINE=InnoDB DEFAULT CHARSET=utf8;