Search code examples
performancedatabase-designfile-managementfile-storage

General question: Filesystem or database?


I want to create a small document management system. There are several users who store their files. Each file which is uploaded contains info about which user uploaded it and the document content itself. In a view all files of ONE specific user will be displayed, ordered by date.

What would be better:

  1. giving the documents a name or metadata (XML) which contain the date and user (and iterate through them to get the metadata) or...

  2. giving the files a random/unique name and store metadata in a DB? something like this:

    date | user | filename
    

What would you say and why? The used programming language is Java and the DB is MySQL.


Solution

  • I would choose the DB. DB's are faster, safer (you don't by accident delete important files) and easier. Also, this is the purpose of a DB: managing large a mounts of data. Filesystems are for storing files.

    But the choise is of course to you.

    But I guarantee: (DB > XML) == true in performance, and (DB >= XML) == false in filesize!