I have not much experience with MySQL or SQL in general, and I don’t want to dive into it too deeply. But I just wanna ask this:
I’ve got two columns, like this:
CREATE TABLE foo(parent INT(11) unsigned NOT NULL, ordering INT);
I just want a constraint that makes sure that if the parent key is the same, the ordering must be different. Or in maths:
For all f1,f2 in foo: parent(f1) = parent(f2) => ordering(f1) =/= ordering(f2)
How can I express that in MySQL?
I assume that
=/=means “not equal” (which would be!=or<>in SQL terminology).A unique index on (parent, ordering) should do that: