How to create a circular reference ?

  • Dear all,

    I would like to know if it is possible to create a circular reference on a table.

    Example:

    For a company heirarchy, I create a table that contain 2 fields that are the PersonelID and the PersonelID of his N+1.

    Now with this 2 fields I would like to retreive the complete structure ?


    Best regards,

    Michael.

  • Hi gedeon,

    In the table PersonelID is the key. Add a field for the PersonlID of the person's supervisor. That field will be related to the key field. In other words, a person's supervisor must be in the personel table. The King of the hill will be his own supervisor.

    Mike

  • The proposed methods work without any problem. Either using a second table for setting the relations, or adding the 'supervisor_id' to the personnel table.

    However, there is no easy way to run through such a structure, if its multi-tiered. E.g. get all supervisors (on all levels) for person X. You will have to use a cursor loop for that.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply