r/AskProgrammers • • 10m ago

Design a database for folder heirarchy.

I am building a cloud storage application in which we can store data in a folder hierarchy.

But struggling to design a database schema to store the folders.
I am using Adjacency list approach in which I store folder id and its parent id in a row so that I can fetch all the child nodes of a folder easily with simple query.
But the problem arises when I wants to delete a folder in that case I would have to first get all the children throughout the hierarchy and delete them all which will be pretty bas in a really big folder structure. It will be hard to share the folder with others.
Any suggestion ?

1 Upvotes

0 comments sorted by