Best Relational DataBase Representation Of Time Bound Hierarchies

后端 未结 4 1540
温柔的废话
温柔的废话 2021-02-02 04:27

What in everyone\'s opinion is the best representation for a time-bound hierarchy in SQL?

What I mean by this is:
- On any given date you have a normal tree hierarch

4条回答
  •  故里飘歌
    2021-02-02 04:48

    table item(id, ...)
    
    table item_link(parent_item, child_item, from_date, until_date)
    

    The links will store the representation of the tree for a certain time

    This structure represents a network instead of a plain hierarchy but it supports moving things in a hierarchy but also look back in time. Some things need to be checked in application logic is to disallow joe being linked at different places in the hierarchy at the sametime.

    Reporting is relatively easy with connect by prior clause (in oracle)

    Other details can be related to item or even item link if it is to specify additional data on the relation.

提交回复
热议问题