26.02.2013, 16:13
You're doing it all wrong! A foreign key (or simply relation) links two pieces of the same data together, that are in different tables. Userid needs to be linked with userid, not vehicleid with userid. That will never work.
Refer to this picture; here I link the player's weapons (child table) to the player's main data (parent table) by means of the player's unique identifier. The point of doing this is: in the event the userid gets changed or deleted, all rows in the child table(s) will also get updated or deleted.
Refer to this picture; here I link the player's weapons (child table) to the player's main data (parent table) by means of the player's unique identifier. The point of doing this is: in the event the userid gets changed or deleted, all rows in the child table(s) will also get updated or deleted.