Reputation:
I'm wondering how to rapresent the file system metaphor (ntfs is based on btree right?) inside a SQL database. Obviously data are stored as rows into tables and don't use the NTFS storing method; so, how NTFS (and other FS) logically works to rapresent the files/folders hierachy? Any advice or references?
Thanks for the support.
Upvotes: 1
Views: 125
Reputation: 46080
If you want to have some kind of database, stored in DBMS, simply build the table with the following fields:
and that's it. ID/ParentID would let you build a hierarchy, and the rest is details.
Most filesystems have inverted structure of ID/ChildrenIDList instead of ID/ParentID but this is caused by specifics of filesystem design. If the filesystem is backed by some relational DBMS, then having a parent ID might be more optimal for lookup.
Upvotes: 1