Storing folder hierarchy in relational database

前端 未结 4 1158
执笔经年
执笔经年 2021-01-13 02:15

I have objects representing folders and I\'m wondering if they should be represented in the database.

On the one hand it seems like the easiest way would be to not r

4条回答
  •  借酒劲吻你
    2021-01-13 03:14

    The idea is something like this (self-referencing):

    CREATE TABLE FileSystemObject ( 
        ID int not null primary key identity,
        Name varchar(100) not null,
        ParentID int null references FileSystemObject(ID),
        constraint uk_Path UNIQUE (Name, ParentID),
        IsFolder bit not null
    )
    

提交回复
热议问题