Can a table have two foreign keys?

前端 未结 4 1805
一整个雨季
一整个雨季 2021-02-02 10:02

I have the following tables (Primary key in bold. Foreign key in Italic)

Customer table

  • ID---Name---Balance---
4条回答
  •  再見小時候
    2021-02-02 10:39

    The foreign keys in your schema (on Account_Name and Account_Type) do not require any special treatment or syntax. Just declare two separate foreign keys on the Customer table. They certainly don't constitute a composite key in any meaningful sense of the word.

    There are numerous other problems with this schema, but I'll just point out that it isn't generally a good idea to build a primary key out of multiple unique columns, or columns in which one is functionally dependent on another. It appears that at least one of these cases applies to the ID and Name columns in the Customer table. This allows you to create two rows with the same ID (different name), which I'm guessing you don't want to allow.

提交回复
热议问题