所以我用的是一个在数据库中大量存储图像的应用程序。你对此有什么看法?我更倾向于将位置存储在文件系统中,而不是直接存储在DB中。

你认为优点和缺点是什么?


当前回答

The word on the street is that unless you are a database vendor trying to prove that your database can do it (like, let's say Microsoft boasting about Terraserver storing a bajillion images in SQL Server) it's not a very good idea. When the alternative - storing images on file servers and paths in the database is so much easier, why bother? Blob fields are kind of like the off-road capabilities of SUVs - most people don't use them, those who do usually get in trouble, and then there are those who do, but only for the fun of it.

其他回答

在以前的一个项目中,我将图像存储在文件系统上,这在备份、复制和文件系统与数据库不同步方面造成了很多麻烦。

在我最新的项目中,我将图像存储在数据库中,并将它们缓存到文件系统中,它工作得非常好。到目前为止我还没有遇到任何问题。

如果你正在计划一个面向公众的网站,那么你不应该选择任何一个选项。您应该使用内容分发网络(CDN)。在互联网上传递大量静态内容时,CDN具有价格、可扩展性和速度优势。

没有人提到的是DB保证原子操作、事务完整性和处理并发性。对于文件系统,甚至引用完整性都不存在了——那么您如何知道您的文件名仍然是正确的呢?

如果你的文件系统中有你的图像,当你写一个新版本甚至删除文件时,有人正在读取文件-会发生什么?

我们使用blob是因为它们也更容易管理(备份、复制、传输)。他们为我们工作得很好。

I have worked with many digital storage systems and they all store digital objects on the file system. They tend to use a branch approach, so there will be an archive tree on the file system, often starting with year of entry e.g. 2009, subdirectory will be month e.g. 8 for August, next directory will be day e.g. 11 and sometimes they will use hour as well, the file will then be named with the records persistent ID. Using BLOBS has its advantages and I have heard of it being used often in the IT parts of the chemical industry for storing thousands or millions of photographs and diagrams. It can provide more granular security, a single method of backup, potentially better data integrity and improved inter media searching, Oracle has many features for this within the package they used to call Intermedia (I think it is called something else now). The file system can also have granular security provided through a system such as XACML or another XML type security object. See D Space of Fedora Object Store for examples.

你的网络服务器(我假设你正在使用)是用来处理图像的,而数据库不是。因此,我会大力投反对票。

在数据库中只存储路径(可能还有文件信息)。