Originally posted by Avi Abrami:
Julien,
I have no experience with "mysql", but I know of several databases that allow you to define a multi-column primary key for a database table and then the database server ensures that the primary key is unique.
So I believe you simply need to define a primary key.
Good Luck,
Avi.
MySQL has a 16 field limit on unique indices, hence Julien's predicament.
The trigger itself would be fairly basic, wouldn't it? It would need to be a before insert or update trigger that does a select for the count of rows based on the unique fields.
The trigger logic would need to run in a transaction to you could roll it back if the row already exists. I
think this is the only way to prevent an insert/update via a trigger (someone else might know better)?
The MySQL
manual has quite a lot about triggers. It should get you going.
[ August 05, 2008: Message edited by: Paul Sturrock ]