开发者

Relational database design:two 1 to many relations

开发者 https://www.devze.com 2023-03-04 23:15 出处:网络
I have i table users (id,name) and operations (id,date,id_user,id_target_user) if i didn\'t have the id_target_user column I\'ll just make on relation

I have i table users (id,name) and operations (id,date,id_user,id_target_user)

if i didn't have the id_target_user column I'll just make on relation from the users.id to operations.id_user (every user can have multiple several operations) but the problem is the operat开发者_如何学JAVAion maybe related to another user

how to solve this? i can't create 2 relations on the same key can i?


Yes you can.

  • id_user is a foreign key to users.id.

  • id_target_user is a foreign key to users.id.

That's all you need.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号