SQL Server foreign key to multiple tables

前端 未结 5 1298
情话喂你
情话喂你 2020-12-11 19:04

I have the following database schema:

members_company1(id, name, ...);
members_company2(id, name, ...);
profiles(memberid, membertypeid, ...);
membertypes(id         


        
5条回答
  •  有刺的猬
    2020-12-11 19:11

    No. A foreign key can reference one and only one primary key and there is no way to spread primary keys across tables. The kind of logic you hope to achieve will require use of a trigger or restructuring your database so that all members are based off a core record in a single table.

提交回复
热议问题