将数据存储在服务器上的文件中而不是数据库中?
将数据存储在文件而不是数据库中会带来哪些问题? 我正在考虑像博客引擎这样的东西。 我读到 MoveableType 曾经这样做过。 这种工作方式的优点/缺点是什么?
What are the problems associated with storing your Data in files rather than databases? I'm thinking in terms of something like a blog engiene. I read that MoveableType used to do this. What are the pros/cons of working this way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
数据库提供了更轻松地执行有趣查询的方法。
示例:您希望在首页上列出 10 个最新帖子。 创建一个存档页面,列出给定年份发布的所有文章(取自 url)。
Databases provide means to perform interesting queries more easily.
Examples: You would want to list the 10 most recent posts on the front page. Make an archive page that lists all articles published in a given year (taken from the url).
我认为最主要的是数据的一致性。 如果将所有内容都保存在一个数据库表中,则不必(同样)担心文件被外部修改或删除,而元数据没有同步修改。 如果更新时服务器出现故障,也可能会出现写入不完整的情况。 在这种情况下,您必须采取自己的步骤来实施交易。
我认为,通过适当的关注和文件权限,这些问题是可以克服的。
I think the main one is data consistency. If you keep everything together in one db table, you don't have to worry (as much) about the file being externally modified or deleted without the meta data being modified in sync. There's also the possibility of an incomplete write if the server fails while you're updating. In this case you have to take your own steps to implement transactions.
I think that with an appropriate level of care and file permissions though, these problems can be overcome.
在数据库中指定访问权限(对数据或文件)比使用操作系统特定的访问权限要容易得多、更舒服。
您可以使用数据库存储的文件在计算机和/或网站之间轻松共享数据。
不幸的是,提供存储在数据库中的文件(通常)要慢得多。
不幸
It is much easier and more comfortable to specify access rights (to data or file) in database than to use OS specific access rights.
You can easily share data across machines and/or websites using database-stored files.
Unfortunately, it is (often) much slower to serve files stored in database.