Reputation: 13
I have a 'users' table, and there is also a table 'alerts'. And in the 'alert' table, I want to use 'users.id' two times representing two different users of a 'users' table as a foreign keys in 'alert' table.
Is it possible? if not then what will be the alternate solution? Kindly help me. Thanks in advance :-)
Upvotes: 0
Views: 47
Reputation: 1271003
You would express this as:
create table alerts (
. . . ,
user_id_from int,
user_id_to int,
foreign key (alerts_user_id_from) references users(user_id),
foreign key (alerts_user_id_to) references users(user_id)
);
I just made up the column names to give you an example of how it would work.
Upvotes: 1