Reputation: 521
I have to make a "virtual filesystem" in MySql (using asp.net as the web-application). It's not going to be very complex, probably maximum 2-3 subfolders "deep", with maybe up to 10 files in each folder. Each user will have their own folders and files after they log in. The admin(s) should be able to make "templates", and assign a template to new users. A template will have a few folders and files in it. And this is what I'm scratching my head on how to make. I think I'm at least close to design the tables, but I'm not sure. Here is the tables I've created so far:
Files
ID
Name
ContentType
FileDataSize
FileData
Parent_Folder_ID
Folders
ID
Name
Parent_Folder_ID
Users
ID
Name
Email
Password
Templates
ID
Name
User_Templates
User_ID
Template_ID
Am i on the right track here? Or am I missing something?
Upvotes: 0
Views: 63
Reputation: 99533
This looks pretty simple, and this will probably just work for your purposes. The only problem you will run into, is that you will need several queries to determine the the full path for a leaf node.
The easiest way to solve this, is to actually store the full path in a separate column, such as:
folder1/folder2/node
Not as pretty, but certainly the absolute easiest to deal with.
Alternatively, you could use the preorder tree traversal algorithm, but this can be more complex, and while fetching sub-tree's is fast, updates may be incredibly slow.
Upvotes: 1