╔═══════════╦══════╦══════════════════════════════════╗
║ Column ║ Type ║ Description ║
╠═══════════╬══════╬══════════════════════════════════╣
║ id ║ int ║ Unique identifier of the folder ║
║ parent_id ║ int ║ id of the parent folder ║
║ name ║ text ║ Name of the folder ║
║ mpath ║ text ║ Materialized path of parent id's ║
╚═══════════╩══════╩══════════════════════════════════╝
最好将文件夹结构存储在一个表中,而不是为每个文件夹创建一个表。在
例如,这样的表可以具有如下结构:
关于具体化路径的注意事项:它是可选的,可以添加它来更快地运行查询,比如“getallchildoffolder123”,而不需要重复调用。在
假设你有这样的文件夹结构:
^{pr2}$可以如下表的形式表示:
在python中,您可以使用一些ORM,例如sqlAlchemy,在这种情况下,您的文件夹将被表示为一个类,实现模型:
^{4}$自动创建mpath值的功能也可以放在这个类中。在
相关问题 更多 >
编程相关推荐