Self Join Scenario

Hai,
I have a table which references with itself know as self join.
I have an employee table where emp_id is primary key. another column called manager_id which is referencing to emp_id only. becoz manager also employee in the organization.
how can we generate hub and link structures in this situation ?

you just answered your own question, hierarchical link joins the same hub table… nuff said

3 Likes

When loading the employee table into the data vault structure, you would have 2 hub entries (one or both may already exist) : emp_id and emp_id (mgr_id). The link table would have both keys. I think it’s a choice as to whether the order of the keys in the link implies the relationship (hazardous) or there is an attribute on the link that identifies the nature of the relationship. (the latter is more robust as it could potentially allow for other types of relationships between employees.)

Mate… think about how the link will look like when joining to the same hub

Link-HashKey: dv_hashkey_link_emp_mgr
Hub-HashKey1: dv_hashkey_hub_employee
Hub-HashKey2: dv_hashkey_hub_manager

Why do you need another column to indicate which is the manager and which is the employee?

1 Like