Imagine that you have a table in which two columns together form a constraint. For example, you have a category table that has a reference to a section (a different table) and a name. Now, you want that category names should be unique within a section. You can insert any section multiple times, and you can use any name multiple times. But you can not have insert the same section and name multiple times.
How do you about it? Simple, use constraints on a group of columns, of course. It’s just that I didn’t have a clue that this worked until today. I had seen something like UNIQUE(a, b) some time back, but I thought it was just a short-hand for setting unique constraints on multiple columns in one go.
Well, I was wrong. It actually sets up a constraint on the columns as a group. That is so cool! Since my database server assures that I cannot insert a duplicate name within a section, I don’t have write loads of code to do it. In fact, I can trim down my code a bit this evening.
I think I am just about the only person in the whole world who didn’t know about this already. Of course, if I had taken my time to RTFM, I would also have known..