开发者

File save on File System VS In Database

I'm designing a servlet(or action in Struts2) for file(images, documents, etc...) download. But I'm wondering which is better approach开发者_如何学JAVA to keep files on File system and in database just keep the path to the file OR to keep the files in the database like BLOBs. I know that when I do query on database where is blobs is slower, but if I keep in database It would me it easier to backup the data and guarantee consistency. Any suggestions?


I never used a BLOB. E.g. I just store user uploaded photos normally in directories. I don't see much reason for using a BLOB for storing files. You say it could be easier to backup - on the contrary, that could become very problematic, at least in our case as we have many GB of photos, but the database must be kept rather small in order to be able to backup it often and with PHPMyAdmin.


I think that you gave a good solution: store files themselves in file system an references in DB. Storing media files in relational DB does not give you serious advantages but increases DB volume and decreases performance (as mentioned by @Amir Raminfar).

Probably good approach these days is to store files in key-value-store or so called NoSql database, e.g. Casandra or Redis.


I am with storing the data on disk because of one important factor: performance. The rest is your preference. Here is a link with better comparison.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜