If I have a table that looks like this
CREATE TABLE foo (
id INT NOT NULL AUTO_INCREMENT,
aa INT NOT NULL,
bb INT NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY (aa, bb),
CONSTRAINT aa_ref FOREIGN KEY (aa) REFERENCES bar (id),
CONSTRAINT bb_ref FOREIGN KEY (bb) REFERENCES bar (id)
)
Is there a way to make sure that aa != bb besides using application level logic or forcing a trigger to fail on BEFORE INSERT?