Multiple yet mutually exclusive foreign keys - is this the way to go?

前端 未结 6 847
自闭症患者
自闭症患者 2020-12-10 17:13

I have three tables: Users, Companies and Websites. Users and companies have websites, and thus each user record has a foreign key into the Websites table. Also, each compa

6条回答
  •  天涯浪人
    2020-12-10 17:35

    you don’t need a parent column, you can lookup the parents with a simple select (or join the tables) on the users and companies table. if you want to know if this is a user or a company website i suggest using a boolean column in your websites table.

提交回复
热议问题