请输入您要查询的百科知识:

 

词条 Document-oriented database
释义

  1. Documents

      CRUD operations    Keys    Retrieval    Editing    Organization  

  2. Relationship to other databases

      Relationship to key-value stores    Relationship to search engines    Relationship to relational databases  

  3. Implementations

     XML database implementations 

  4. See also

  5. Notes

  6. References

  7. Further reading

  8. External links

{{about|the software type|deployed applications of the software type|Full-text database}}{{primary sources|date=May 2012}}

A document-oriented database, or document store, is a computer program designed for storing, retrieving and managing document-oriented information, also known as semi-structured data.

Document-oriented databases are one of the main categories of NoSQL databases, and the popularity of the term "document-oriented database" has grown[1] with the use of the term NoSQL itself. XML databases are a subclass of document-oriented databases that are optimized to work with XML documents. Graph databases are similar, but add another layer, the relationship, which allows them to link documents for rapid traversal.

Document-oriented databases are inherently a subclass of the key-value store, another NoSQL database concept. The difference lies in the way the data is processed; in a key-value store, the data is considered to be inherently opaque to the database, whereas a document-oriented system relies on internal structure in the document in order to extract metadata that the database engine uses for further optimization. Although the difference is often moot due to tools in the systems,{{efn|To the point that document-oriented and key-value systems can often be interchanged in operation.}} conceptually the document-store is designed to offer a richer experience with modern programming techniques.

Document databases{{efn|And key-value stores in general.}} contrast strongly with the traditional relational database (RDB). Relational databases generally store data in separate tables that are defined by the programmer, and a single object may be spread across several tables. Document databases store all information for a given object in a single instance in the database, and every stored object can be different from every other. This eliminates the need for object-relational mapping while loading data into the database.

Documents

The central concept of a document-oriented database is the notion of a document. While each document-oriented database implementation differs on the details of this definition, in general, they all assume documents encapsulate and encode data (or information) in some standard format or encoding. Encodings in use include XML, YAML, JSON, and BSON, as well as binary forms like PDF and Microsoft Office documents (MS Word, Excel, and so on).

Documents in a document store are roughly equivalent to the programming concept of an object. They are not required to adhere to a standard schema, nor will they have all the same sections, slots, parts or keys. Generally, programs using objects have many different types of objects, and those objects often have many optional fields. Every object, even those of the same class, can look very different. Document stores are similar in that they allow different types of documents in a single store, allow the fields within them to be optional, and often allow them to be encoded using different encoding systems. For example, the following is a document, encoded in JSON:

{
    "FirstName": "Bob",     "Address": "5 Oak St.",     "Hobby": "sailing"

}

A second document might be encoded in XML as:

BobSmith(123) 555-0178(890) 555-0133
Home123 Back St.BoysAR32225US

These two documents share some structural elements with one another, but each also has unique elements. The structure and text and other data inside the document are usually referred to as the document's content and may be referenced via retrieval or editing methods, (see below). Unlike a relational database where every record contains the same fields, leaving unused fields empty; there are no empty 'fields' in either document (record) in the above example. This approach allows new information to be added to some records without requiring that every other record in the database share the same structure.

Document databases typically provide for additional metadata to be associated with and stored along with the document content. That metadata may be related to facilities the datastore provides for organizing documents, providing security, or other implementation specific features.

CRUD operations

The core operations that a document-oriented database supports for documents are similar to other databases, and while the terminology is not perfectly standardized, most practitioners will recognize them as CRUD:

  • Creation (or insertion)
  • Retrieval (or query, search, read or find)
  • Update (or edit)
  • Deletion (or removal)

Keys

Documents are addressed in the database via a unique key that represents that document. This key is a simple identifier (or ID), typically a string, a URI, or a path. The key can be used to retrieve the document from the database. Typically the database retains an index on the key to speed up document retrieval, and in some cases the key is required to create or insert the document into the database.

Retrieval

Another defining characteristic of a document-oriented database is that, beyond the simple key-to-document lookup that can be used to retrieve a document, the database offers an API or query language that allows the user to retrieve documents based on content (or metadata). For example, you may want a query that retrieves all the documents with a certain field set to a certain value. The set of query APIs or query language features available, as well as the expected performance of the queries, varies significantly from one implementation to another. Likewise, the specific set of indexing options and configuration that are available vary greatly by implementation.

It is here that the document store varies most from the key-value store. In theory, the values in a key-value store are opaque to the store, they are essentially black boxes. They may offer search systems similar to those of a document store, but may have less understanding about the organization of the content. Document stores use the metadata in the document to classify the content, allowing them, for instance, to understand that one series of digits is a phone number, and another is a postal code. This allows them to search on those types of data, for instance, all phone numbers containing 555, which would ignore the zip code 55555.

Editing

Document databases typically provide some mechanism for updating or editing the content (or other metadata) of a document, either by allowing for replacement of the entire document, or individual structural pieces of the document.

Organization

Document database implementations offer a variety of ways of organizing documents, including notions of

  • Collections: groups of documents, where depending on implementation, a document may be enforced to live inside one collection, or may be allowed to live in multiple collections
  • Tags and non-visible metadata: additional data outside the document content
  • Directory hierarchies: groups of documents organized in a tree-like structure, typically based on path or URI

Sometimes these organizational notions vary in how much they are logical vs physical, (e.g. on disk or in memory), representations.

Relationship to other databases

Relationship to key-value stores

A document-oriented database is a specialized key-value store, which itself is another NoSQL database category. In a simple key-value store, the document content is opaque. A document-oriented database provides APIs or a query/update language that exposes the ability to query or update based on the internal structure in the document. This difference may be moot for users that do not need richer query, retrieval, or editing APIs that are typically provided by document databases. Modern key-value stores often include features for working with metadata, blurring the lines between document stores.

Relationship to search engines

Some search engines (aka information retrieval) systems like Elasticsearch provide enough of the core operations on documents to fit the definition of a document-oriented database.

Relationship to relational databases

{{cleanup|section|reason="Requires cleanup"|date=July 2016}}

In a relational database, data is first categorized into a number of predefined types, and tables are created to hold individual entries, or records, of each type. The tables define the data within each record's fields, meaning that every record in the table has the same overall form. The administrator also defines the relationships between the tables, and selects certain fields that they believe will be most commonly used for searching and defines indexes on them. A key concept in the relational design is that any data that may be repeated is normally placed in its own table, and if these instances are related to each other, a column is selected to group them together, the foreign key. This design is known as database normalization.[2]

For example, an address book application will generally need to store the contact name, an optional image, one or more phone numbers, one or more mailing addresses, and one or more email addresses. In a canonical relational database, tables would be created for each of these rows with predefined fields for each bit of data: the CONTACT table might include FIRST_NAME, LAST_NAME and IMAGE columns, while the PHONE_NUMBER table might include COUNTRY_CODE, AREA_CODE, PHONE_NUMBER and TYPE (home, work, etc.). The PHONE_NUMBER table also contains a foreign key column, "CONTACT_ID", which holds the unique ID number assigned to the contact when it was created. In order to recreate the original contact, the database engine uses the foreign keys to look for the related items across the group of tables and reconstruct the original data.

In contrast, in a document-oriented database there may be no internal structure that maps directly onto the concept of a table, and the fields and relationships generally don't exist as predefined concepts. Instead, all of the data for an object is placed in a single document, and stored in the database as a single entry. In the address book example, the document would contain the contact's name, image, and any contact info, all in a single record. That entry is accessed through its key, which allows the database to retrieve and return the document to the application. No additional work is needed to retrieve the related data; all of this is returned in a single object.

A key difference between the document-oriented and relational models is that the data formats are not predefined in the document case. In most cases, any sort of document can be stored in any database, and those documents can change in type and form at any time. If one wishes to add a COUNTRY_FLAG to a CONTACT, this field can be added to new documents as they are inserted, this will have no effect on the database or the existing documents already stored. To aid retrieval of information from the database, document-oriented systems generally allow the administrator to provide hints to the database to look for certain types of information. These work in a similar fashion to indexes in the relational case. Most also offer the ability to add additional metadata outside of the content of the document itself, for instance, tagging entries as being part of an address book, which allows the programmer to retrieve related types of information, like "all the address book entries". This provides functionality similar to a table, but separates the concept (categories of data) from its physical implementation (tables).

In the classic normalized relational model, objects in the database are represented as separate rows of data with no inherent structure beyond that given to them as they are retrieved. This leads to problems when trying to translate programming objects to and from their associated database rows, a problem known as object-relational impedance mismatch.[3] Document stores more closely, or in some cases directly, map programming objects into the store. These are often marketed using the term NoSQL.

Implementations

{{main cat|Document-oriented databases}}
Name Publisher License Languages supported Notes RESTful API
AllegroGraph Franz, Inc. {{proprietary}} Java, Python, Common Lisp, Ruby, Scala, .NET, Perl The database platform supports document store and graph data models in a single database. Supports JSON, JSON-LD, RDF, full-text search, ACID, two-phase commit, Multi-Master Replication, Prolog and SPARQL. {{yes}}[4]
ArangoDB ArangoDBApache License}} C, .NET, Java, Python, Node.js, PHP, Scala, Go, Ruby, Elixir The database system supports document store as well as key/value and graph data models with one database core and a unified query language AQL (ArangoDB Query Language). {{yes}}[5]
BaseX BaseX TeamBSD License}} Java, XQuery Support for XML, JSON and binary formats; client-/server based architecture; concurrent structural and full-text searches and updates. {{yes}}
Caché InterSystems Corporation {{proprietary}} Java, C#, Node.js Commonly used in Health, Business and Government applications. {{yes}}
Cloudant Cloudant, Inc. {{proprietary}} Erlang, Java, Scala, and C Distributed database service based on BigCouch, the company's open source fork of the Apache-backed CouchDB project. Uses JSON model. {{yes}}
Clusterpoint Database Clusterpoint Ltd. {{proprietary}} with free download JavaScript, SQL, PHP, .NET, Java, Python, Node.js, C, C++, Distributed document-oriented XML / JSON database platform with ACID-compliant transactions; high-availability data replication and sharding; built-in full-text search engine with relevance ranking; JS/SQL query language; GIS; Available as pay-per-use database as a service or as an on-premise free software download. {{yes}}
Couchbase Server Couchbase, Inc.Apache License}} C, .NET, Java, Python, Node.js, PHP, SQL, Go, Spring Framework, LINQDistributed NoSQL Document Database, JSON model and SQL based Query Language. {{yes}}[6]
CouchDB Apache Software FoundationApache License}} Any language that can make HTTP requests JSON over REST/HTTP with Multi-Version Concurrency Control and limited ACID properties. Uses map and reduce for views and queries.[7] {{yes}}[8]
CrateIO CRATE Technology GmbHApache License}} Java Use familiar SQL syntax for real time distributed queries across a cluster. Based on Lucene / Elasticsearch ecosystem with built-in support for binary objects (BLOBs). {{yes}}[9]
Cosmos DB Microsoft {{proprietary}} .NET, Java, Python, Node.js, JavaScript, SQL Platform-as-a-Service offering, part of the Microsoft Azure platform. Builds upon and extends the earlier Azure DocumentDB. {{yes}}
DocumentDBAmazon Web Services Proprietary online service various, REST fully managed MongoDB v3.6-compatible database service{{yes}}
ElasticsearchShay BanonApache License}}JavaJSON, Search engine.{{yes}}
eXist eXistLGPL}} XQuery, Java XML over REST/HTTP, WebDAV, Lucene Fulltext search, binary data support, validation, versioning, clustering, triggers, URL rewriting, collections, ACLS, XQuery Update {{yes}}[10]
Informix IBM Proprietary, with no-cost editions[11] Various (Compatible with MongoDB API) RDBMS with JSON, replication, sharding and ACID compliance. {{yes}}
JackrabbitApache FoundationApache License}}JavaJava Content Repository implementation{{dunno}}
Lotus Notes (IBM Lotus Domino) IBM {{proprietary}} LotusScript, Java, Lotus @Formula MultiValue {{yes}}
MarkLogic MarkLogic Corporation Free Developer license or Commercial[12]Java, JavaScript, Node.js, XQuery, SPARQL, XSLT, C++ Distributed document-oriented database for JSON, XML, and RDF triples. Built-in full-text search, ACID transactions, high availability and disaster recovery, certified security. {{yes}}
MongoDB MongoDB, Inc Server Side Public License for the DBMS, Apache 2 License for the client drivers[13] C, C++, C#, Java, Perl, PHP, Python, Node.js, Ruby, Rust [14], Scala [15] Document database with replication and sharding, BSON store (binary format JSON). {{yes}}[16]
MUMPS Database {{dunno}} Proprietary and Affero GPL[17] MUMPS Commonly used in health applications. {{dunno}}
ObjectDatabase++ Ekky Software {{proprietary}} C++, C#, TScript Binary Native C++ class structures {{dunno}}
OpenLink VirtuosoOpenLink SoftwareGPLv2[1] and proprietaryC++, C#, Java, SPARQLMiddleware and database engine hybrid{{yes}}
OrientDB Orient TechnologiesApache License}} Java JSON over HTTP, SQL support, ACID transactions {{yes}}
PostgreSQL PostgreSQLPostgreSQL Free License}}[18] C HStore, JSON store (9.2+), JSON function (9.3+), HStore2 (9.4+), JSONB (9.4+){{no}}
Qizx Qualcomm {{proprietary}} REST, Java, XQuery, XSLT, C, C++, Python Distributed document-oriented XML database with integrated full-text search; support for JSON, text, and binaries.{{yes}}
RethinkDB {{dunno}}GNU AGPL for the DBMS, Apache 2 License for the client drivers}} C++, Python, JavaScript, Ruby, Java Distributed document-oriented JSON database with replication and sharding.{{no}}
SAP HANASAP{{proprietary}}SQL-like languageACID transaction supported, JSON only{{yes}}
Sednasedna.orgApache License}}C++, XQueryXML database{{no}}
SimpleDBAmazon Web Services Proprietary online serviceErlang{{dunno}}
Solr ApacheApache License}}JavaSearch engine{{yes}}
TokuMXTokutekGNU Affero General Public License}}C++, C#, GoMongoDB with Fractal Tree indexing{{dunno}}

XML database implementations

{{Further information|XML database}}

Most XML databases are document-oriented databases.

See also

  • Database theory
  • Data hierarchy
  • Full-text search
  • In-memory database
  • Internet Message Access Protocol (IMAP)
  • Machine-Readable Documents
  • NoSQL
  • Object database
  • Online database
  • Real-time database
  • Relational database

Notes

{{notelist}}

References

1. ^{{cite web|url=http://db-engines.com/en/ranking_categories|title=DB-Engines Ranking per database model category|publisher=}}
2. ^{{cite web |url=https://support.microsoft.com/en-ca/kb/283878 |title=Description of the database normalization basics |website=Microsoft}}
3. ^{{cite web |url=http://www.agiledata.org/essays/impedanceMismatch.html |title=The Object-Relational Impedance Mismatch |first=Scott |last=Wambler |website=Agile Data}}
4. ^{{cite web|url=https://franz.com/agraph/support/documentation/current/http-protocol.html|title=HTTP Protocol for AllegroGraph|publisher=}}
5. ^[https://www.arangodb.com]
6. ^Documentation {{webarchive|url=https://web.archive.org/web/20120820182153/http://www.couchbase.com/docs/ |date=2012-08-20 }}. Couchbase. Retrieved on 2013-09-18.
7. ^CouchDB Overview {{webarchive |url=https://web.archive.org/web/20111020074113/http://couchdb.apache.org/docs/overview.html |date=October 20, 2011 }}
8. ^{{cite web|url=http://wiki.apache.org/couchdb/HTTP_Document_API|title=HTTP_Document_API - Couchdb Wiki|publisher=}}
9. ^{{cite web|url=https://crate.io/docs/stable/sql/rest.html |title=Archived copy |accessdate=2015-06-22 |deadurl=yes |archiveurl=https://web.archive.org/web/20150622174526/https://crate.io/docs/stable/sql/rest.html |archivedate=2015-06-22 |df= }}
10. ^eXist-db Open Source Native XML Database. Exist-db.org. Retrieved on 2013-09-18.
11. ^{{cite web|url=http://www.ibm.com/developerworks/data/library/techarticle/dm-0801doe/|title=Compare the Informix Version 12 editions|date=22 July 2016|publisher=}}
12. ^{{cite web|url=http://developer.marklogic.com/licensing|title=MarkLogic Licensing|publisher=}}
13. ^{{cite web|url=http://www.mongodb.org/about/licensing/|title=MongoDB Licensing|publisher=}}
14. ^{{Cite news|url=https://www.mongodb.com/blog/post/the-new-mongodb-rust-driver|title=The New MongoDB Rust Driver|work=MongoDB|access-date=2018-02-01|language=en-us}}
15. ^{{cite web|url=http://docs.mongodb.org/ecosystem/drivers/community-supported-drivers/|title=Community Supported Drivers Reference|publisher=}}
16. ^MongoDB REST Interfaces
17. ^{{cite web|url=http://sourceforge.net/projects/fis-gtm/|title=GT.M High end TP database engine|publisher=}}
18. ^http://www.postgresql.org/about/licence/

Further reading

  • Assaf Arkin. (2007, September 20). [https://web.archive.org/web/20080327222152/http://blog.labnotes.org/2007/09/20/read-consistency-dumb-databases-smart-services/ Read Consistency: Dumb Databases, Smart Services.]
{{refend}}

External links

  • DB-Engines Ranking of Document Stores by popularity, updated monthly
{{Database models}}{{Databases}}

4 : Document-oriented databases|Data management|Database management systems|Types of databases

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/9/21 8:01:33