Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

songdapeng's avatar

database design for tree(directory and file)

Hi, I am designing database for my document management system and would like to store file as below tree below

Treeview directory_1 directory_1_1 FILE_1_1_1 FILE_1_1_2 FILE_1_1_3 directory_1_2 FILE_1_2_1 FILE_1_2_2 FILE_1_2_3 directory_2 FILE_2_1 FILE_2_2 FILE_2_3 FILE_1 FILE_2 FILE_3

0 likes
2 replies
MohamedTammam's avatar

So? just rename them as you wish or store a parent_id in the database for tree representation.

Tray2's avatar

There is No need to make a fancy directory structure. Just don’t have too many files in the same directoty. Handle the structure in the database instead.

Please or to participate in this conversation.