Make a relation of a table with three different category of id’s table

database-designrelational-theory

I have an issue
There a table that's called "Routing" this table is for routing a task for three category of object

  1. Analyser (interne machine)
  2. subcontractor (externe )

  3. Manually (interne worker)

how to design a relation between 5 tables

   1 - task table -> Routing table -> - analyser table
                                      - subcontractor table 
                                      - Interne user table 

Edit:, answers to questions in comments:

  • Can a task have many routings? Can a routing belong to many tasks or just one?
    No, a task is routed to one routing (the routing is the manner to know where the task should be done).

  • Is there an Analyzer, a Subcontractor and an Interne (ManualWorker) table?
    Yes, there is an analyser table, and subcontractor table, and interne table.

  • Can an analyser be part of many routings (of the same task)?
    Yes, an analyser can be a part of many routing.

  • Can a subcontractor take part in many routings of the same task?
    No, a subcontractor (or analyser or interne) take to one routing of the task (the task is routed to one subctr, or analyser or in interne).

Best Answer

If I have understood what you need is:

TASK TABLE: ID, NAME, DESCR and other attributes

ROUTING TABLE: *ID, IDTASK, INFO and other attributes**

ANALYSER TABLE: ID, IDROUTING and other attributes

SUBCONTRACTOR TABLE: ID, IDROUTING and other attributes

INTERNE USER TALBE: ID, IDROUTING and other attributes

if you want to trace better the relations, you can add in ROUTING TABLE also 3 foreign key like IDANALYSER, IDSUBCONTRACTOR and IDINTERNEUSER. This is not very efficient, because you will have always 2 values null and only one with a value.

But, you can go straight from ROUTING TABLE to the right detailed table.