为什么我应该使用基于文档的数据库,如CouchDB,而不是使用关系数据库。 在哪些典型的应用程序或领域中,基于文档的数据库比关系数据库更适合?
当前回答
愚蠢地存储和提供其他服务器的数据。
在过去的几周里,我一直在玩一个生活流应用程序,它可以调查我的feeds (delicious, flickr, github, twitter…),并将它们存储在couchdb中。couchdb的美妙之处在于,它让我可以在没有开销的情况下将原始数据保留在原始结构中。我为每个文档添加了一个“class”字段,存储源服务器,并为每个源编写了一个javascript渲染类。
一般来说,当您的服务器与另一个服务器通信时,无模式存储是最好的,因为您无法控制模式。作为奖励,couchdb使用服务器和客户端的本机协议——JSON用于表示,HTTP REST用于传输。
其他回答
基于文档的数据库比关系数据库有一个很大的优势,因为它们不需要预先定义模式——在能够输入任何数据之前。
此外,如果您的数据不是关系型的,不能存储在表中,而是一组图像,或例如报纸文章,则应该使用文档数据库。
另一个优点是易于在web开发中使用基于文档的数据库。 要了解更多深入的NoSQL数据库模型比较,请查看这个来源:https://arxiv.org/ftp/arxiv/papers/1509/1509.08035.pdf
如果不需要将数据存储在每个记录具有统一大小字段的表中,则使用基于文档的数据库。相反,您需要将每个记录存储为具有特定特征的文档。任何数量、任何长度的字段都可以在任何时候动态添加到文档中,而不需要首先“修改表”。基于文档的字段也可以包含多个数据。
来自CouchDB文档(https://web.archive.org/web/20090122111651/http://couchdb.apache.org/docs/overview.html):
"A document database server, accessible via a RESTful JSON API." Generally, relational databases aren't simply accessed via REST services, but require a much more complex SQL API. Often these API's (JDBC, ODBC, etc.) are quite complex. REST is quite simple. Ad-hoc and schema-free with a flat address space. Relational databases have complex, fixed schema. You define tables, columns, indexes, sequences, views and other stuff. Couch doesn't require this level of complex, expensive, fragile advanced planning. Distributed, featuring robust, incremental replication with bi-directional conflict detection and management. Some SQL commercial products offer this. Because of the SQL API and the fixed schemas, this is complex, difficult and expensive. For Couch, it appears simple and inexpensive. Query-able and index-able, featuring a table oriented reporting engine that uses Javascript as a query language. So does SQL and relational databases. Nothing new here.
所以。为什么CouchDB ?
REST比JDBC或ODBC更简单。 没有图式比图式更简单。 以一种看起来简单而廉价的方式分布。
也许你不应该:-)
The second most obvious answer is you should use it if your data isn't relational. This usually manifests itself in having no easy way to describe your data as a set of columns. A good example is a database where you actually store paper documents, e.g. by scanning office mail. The data is the scanned PDF and you have some meta data which always exists (scanned at, scanned by, type of document) and lots of possible metadata fields which exists sometime (customer number, supplier number, order number, keep on file until, OCRed fulltext, etc). Usually you do not know in advance which metadata fields you will add within the next two years. Things like CouchDB work much nicer for that kind of data than relational databases.
我个人还喜欢这样一个事实:除了HTTP客户端之外,CouchDB不需要任何客户端库,现在几乎每一种编程语言都包含了HTTP客户端。
可能最不明显的答案是:如果使用RDBMS没有痛苦,那么就继续使用它。如果您总是要绕过RDBMS来完成工作,那么面向文档的数据库可能值得一试。
想要更详细的列表,请查看理查德·琼斯的这篇帖子。
愚蠢地存储和提供其他服务器的数据。
在过去的几周里,我一直在玩一个生活流应用程序,它可以调查我的feeds (delicious, flickr, github, twitter…),并将它们存储在couchdb中。couchdb的美妙之处在于,它让我可以在没有开销的情况下将原始数据保留在原始结构中。我为每个文档添加了一个“class”字段,存储源服务器,并为每个源编写了一个javascript渲染类。
一般来说,当您的服务器与另一个服务器通信时,无模式存储是最好的,因为您无法控制模式。作为奖励,couchdb使用服务器和客户端的本机协议——JSON用于表示,HTTP REST用于传输。
推荐文章
- 获得PostgreSQL数据库中当前连接数的正确查询
- MySQL数据库表中的最大记录数
- 从现有模式生成表关系图(SQL Server)
- HyperLogLog算法是如何工作的?
- 数据库和模式的区别
- 如何从命令行在windows中找到mysql数据目录
- 如何找到MySQL的根密码
- 将表从一个数据库复制到另一个数据库的最简单方法?
- 什么是分片,为什么它很重要?
- 数据库触发器是必要的吗?
- 为什么我应该使用基于文档的数据库而不是关系数据库?
- 哪个更快/最好?SELECT *或SELECT columnn1, colum2, column3等
- 将值从同一表中的一列复制到另一列
- 什么是数据库池?
- 关于数据库,每个开发人员应该知道些什么?