Relationship of 1 attribute with different tables

1

Hello, good afternoon.

I'm modeling my database (MySQL) and a question has arisen. In the bank, among others, I have the following tables: Officials - Sectors - Branches

An Employee works OR in a Headquarters Sector OR in a Branch. I wanted to create a relationship between a work_name attribute of the Employee table with the id tags) of the Sector table > Table or Unit table.

Is this possible? How would you do?

    
asked by anonymous 18.01.2018 / 19:09

2 answers

1

Here's a simple example I've just created for your question. Here is the image below:

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

I hope I have helped.

    
18.01.2018 / 21:26
0

Since the work_location field is related to a or other table, you can not treat it as a foreign key, which you can do, in that case , is to have another field (ex: work_type ) indicating which table the work_site field is being related to     

18.01.2018 / 20:20