POSTGRESQL Foreign Key Referencing Primary Keys of two Different Tables

后端 未结 4 604
旧时难觅i
旧时难觅i 2020-12-02 10:24

I have two tables Books and Audiobooks, both of which have ISBN as their primary keys. I have a table writtenby that has an isbn attribute that has a foreign key constraint

4条回答
  •  离开以前
    2020-12-02 11:10

    In this specific example there is absolutely no need to use multiple tables. Just use the table "Book" and add the columns from "AudioBook", if applicable. If you have to differentiate on table level with very specific columns, create views. Have you checked to see if a "Book" and an "Audio Book" with the same content have the same ISBN?

提交回复
热议问题