For a web application we are planning (some kind of product information system). We have to manage all the assets (pictures) of the products.There are system (Wikis or DAM System) that save the assets in the DB itself or only a reference.What are the criterias to decide wheter the files itslef it should be stored on the FS or DB? The system will manage thumbnails and meta data of the assets.For a PDF production it is possible that we are going to need them on the FS in other cases it is probably better we have them in the DB. (We are working in a windows server environment with mongoDB and C#.)When would it be a disadvantage to have it on the file system (in the DB only meta data)?Or in which situation clearly wins the DB only approach?Update The linked questions brings in some good points. the concern about backup issues with larger DBs: mongoDB's GridFS is good for larger data. We could have a separated asset DB with another backup interval to solve the problem of the longer backup process.Serialization and and deserialization to the FS: Could cost a lot of time. In case we need access to them from third party tools (e.g. for PDF production).
When to Save Assets (mainly Pictures) in DB and when on Filesystem?
programming practices
It is mostly an opinion-based question (and it is surely operating system and file system specific), however:you probably want to avoid having a single directory with many thousands of files (it is file system and operating system specific, but some OS & FS may be unhappy), so prefer dir01/subdir02/file0345.txt to justfile01020345.txtyou probably want to avoid having a big lot of very small files (e.g. less than 2Kbytes).So it might be worthwhile to use a database for small contents (e.g. less than half or a few megabytes) and use file for large contents (several megabytes each). BTW, you could store in your database some metadata about the large enough file (e.g. at least store something related to the pathname).You surely need some backup strategy, and perhaps some cleanup strategy too.Read also about blob-s