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 ?

Answers


just execute this SQL statement in your phpmyadmin.

alter table [your_intermedia_table_name] add unique key(userAsker, userAsked)


Need Your Help

Function fails in IE7, but works in all modern browsers. How can it be fixed?

javascript function internet-explorer-7

I have this JavaScript code to format a number for US dollars that was given many thumbs up on Stackoverflow. It works well in the latest web browsers, but it causes the JavaScript to fail in IE7. ...

Does a way exist to check if an observable is hot or cold?

javascript rxjs

Is there a method in rxjs 4 or 5 to check if an observable is hot or cold?