I've been asked to design folder-like structure (in java, but I expect this solution to be language agnostic).
There is one root, just like
/ on linux. Then, it can have almost indefinitely nested folders and files inside. Now, here's the catch: I have to be able, to track some of file details, like size, on every level. For example, user may want to know, how many files are in Folder 2, and what is their size. To do that, system needs to take every file in Folder 2 (so in this example that would be File5 and File 6), take every folder in it (Folder 4), and every file in Folder4. Folder 4 can have its own nested folders, and they can have more nested folders and files in them as well. Realistically, max level of nested folders will be around 32.
My question is, how to design a system like that? I know I cannot calculate this on the fly. There are just too much data, and user would have too wait for too long. So, I think, there is a necessity to store additional information in folders. Then, they have to be updated every single time a file is changed, and information would have to be propagated up to the root folder. If that changes anything, I'll be using cassandra as database storage.