Can a foreign key reference more than one table?

Asked

Viewed 2,112 times

0

would like to know if it is possible for a foreign key to reference more than one table, for example:

client table
PK - client code
- client name

employee table
PK - official code
- official name

contact table
- telephone
- e-mail
FK - contact code, client table reference(client code), employee table reference (employee code)

  • 1

    I see no sense in such a relationship. Maybe you should consider customer and employee tables as partitioning a single table.

1 answer

3


A foreign key cannot reference more than one table; in fact, this would go against the principles of data logic modeling itself.

The most correct way to relate the tables in the mentioned example would be:

Client table:

  • PK client code

  • FK contact code (reference to contact table)

  • client name

Employee table:

  • PK official code

  • FK contact code (reference to contact table)

  • official name

Table contact:

  • PK contact code
  • telephone
  • e-mail

Browser other questions tagged

You are not signed in. Login or sign up in order to post.