I'm trying to kind of emulate a folder structure in my application. Now I've thought of two ways to achieve this, but what is the best practice for that?

Table: Attachments

Columns: Id (PK), ParentId (FK), Name, FileContent, IsFolder


Table: Attachments

Columns: Id (PK), FolderId (FK), FileContent

Table: AttachmentFolders

Columns: Id (PK), Name

  • 1
    This has been discussed many times. For example: stackoverflow.com/questions/4048151/… – RLF Sep 16 '13 at 15:15
  • What are your requirements? Are folders hierarchical? Can folders move? Can files move? What do you need to retrieve fast? How many files/folder? How many folder? Skew? – Remus Rusanu Sep 16 '13 at 15:16
  • Yes, just like any other filesystem: File/Folder move, rename, delete, update should be possible. What do I need to retrieve fast? All of it. How many files? n. – SeToY Sep 16 '13 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.