Unique foreign key association in intermediate table
I'm a bit new with Mysql and have a problem with unique constraints :p
Here are the tables :
The relation is going to be a intermediate table and the fields are going to be :
ID (primary) userAsker (foreign key) userAsked (foreign key) ((( accept (int) don't care)))
What I would like is that we can't have 2 times an entity whith the same 2 foreign keys like that :
ID : 1 userAsker :1 userAsked : 2
ID : 2 userAsker :1 userAsked : 2
Otherwise the user could be able to do loads of demands ... I know how to do an Index unique in phpmyadmin but I don't know how to group two fields in a unique index ... Could someone help me :S ?
just execute this SQL statement in your phpmyadmin.
alter table [your_intermedia_table_name] add unique key(userAsker, userAsked)