I have objects representing folders, and I wonder if they should be represented in the database.
On the one hand, it seems that the easiest way is not to represent the objects in the folder and just store the path value for the objects contained in the folder. The problems that I see in this is that you cannot save a folder whose descendants do not contain any items, which is not too big for a deal. Also, I don't have a clear idea of how to load the folder hierarchy for display (e.g. in TreeView) without loading everything into memory in advance, which is likely to be a performance issue.
An alternative is the presence of the "Folder" table with links to its parent folder. This seems to work, but I'm not sure how to allow folders with the same name until they share the parent. Should it be something that the database should relate to itself or is it something that I should just apply in business logic?
sql sql-server-ce hierarchy relational folders
Davy8
source share