Storing a directory structure in database

后端 未结 3 948
感情败类
感情败类 2021-02-06 05:06

In my rails app a user can have a directory structure which has folders and files in sub-folders. Which is the best way to store such data ??
Also, which database offers bes

3条回答
  •  伪装坚强ぢ
    2021-02-06 05:27

    If your database supports recursive queries (either Oracle's connect by or the standard recursive common table expressions) then a self referencing table is fine (it's easy to update and query).

    If your DBMS does not support hierarchical queries, then Eimantas suggestion to use a preordered tree traversal scheme is probably the best way.

提交回复
热议问题