一般问题:文件系统还是数据库?
我想创建一个小型文档管理系统。有多个用户存储他们的文件。上传的每个文件都包含有关上传该文件的用户以及文档内容本身的信息。 在视图中,将显示一个特定用户的所有文件,并按日期排序。
更好的做法是:
为文档指定名称或包含日期和用户的元数据 (XML)(并迭代它们以获取元数据)或...
为文件提供随机/唯一名称并将元数据存储在数据库中?像这样的东西:
<前><代码>日期 |用户 |文件名
你会说什么以及为什么? 使用的编程语言是Java,数据库是MySQL。
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:
giving the documents a name or metadata (XML) which contain the date and user (and iterate through them to get the metadata) or...
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我会选择DB。数据库更快、更安全(您不会意外删除重要文件)并且更容易。此外,这也是数据库的目的:管理大量数据。文件系统用于存储文件。
但选择权当然在于你。
但我保证:在性能方面
(DB > XML) == true
,在文件大小方面(DB >= XML) == false
!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!我会选择第二个选项来存储元数据。 MySQL 将处理并发性,并且在数据库中搜索比迭代 XML 文件要快得多。
I would choose the second option for metadata storing. MySQL will handle concurency, and searching in DB is much more faster than iterating an XML file.
那么,如果数据量非常低(假设最大),会怎样?每个用户 30 个文件,假设有 20 个用户 ->最多 600 个文件。您如何判断为每个用户创建单独的文件夹并为文件提供依赖于用户的唯一名称的解决方案?因此您可以轻松地浏览文件系统。在这种情况下,数据库对于如此少量的文档有意义吗?
So what would be, if the amount of data is very low, let's say max. 30 files per user, and let's say 20 users -> 600 files maximum. how would you judge the solution to create a seperate folder for each user and give the files an user reliant unique name? So you can navigate througth the file system easily. in this context, would a DB make sense for this low amount of documents?