Relationship of 1 attribute with different tables

Asked

Viewed 82 times

1

Everybody, good afternoon, everybody.

I’m modeling my database (Mysql) and a question has arisen. In the bank, among others, I have the following tables: Employees - Sectors - Subsidiaries

An Employee works OR in a Headquarters Sector OR in an Affiliate. I wanted to create a relationship between an attribute (local_de_work) table Functionary with the codes (id) table Sector OR TABLE Unity.

Is that possible? How would you do?

  • You put OU, but only for doubt, an employee can have HEADQUARTERS and BRANCH at the same time?

2 answers

1

Here is a simple example that I have just created in view of your question. Below is an image:

inserir a descrição da imagem aqui

Looking at the example I think you can create one according to your needs.

I hope I’ve helped.

0

Once the field local_de_work is related to a or another table, it is not possible to treat it as a Foreign key, what you can do in that case is to have another field (ex: tipo_local_de_work) indicating to which table the field local_de_work is being related

Browser other questions tagged

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