backgroundA document is the main concept in a document database. Such databases can store and retrieve documents, which can be in the form of XML, JSON, Bson, and so on. These documents have child properties, render tree data structures, and can contain mapping tables, collections, and scalar values. Documents in the database are similar to each other, but not necessarily identical. Documents stored in the document database are equivalent to the "values" stored in the key-value database. A document database can be treated as a database of key values that its values can be checked. The popular documentation databases are: MongoDB, CouchDB, Terrastore, Orientdb, RavenDB.
Consistencyin order to ensure consistency in the MongoDB database, you can configure the replica set to also specify that the write operation must wait for the abbreviated data to be copied to all or a given number of slave nodes before it can be returned. Each time you write data, you can specify how many server nodes you must propagate the written data to before the write operation returns. Transactionsfrom the traditional relational database point of view, the word "transaction" means that we first use the INSERT, Update, delete and other commands to exercise different tables, and then commit the modification with commit or rollback with the rollback command. NoSQL databases typically do not have these mechanisms: their write operations either succeed or fail. The "Transaction" at "Single Document level" is called "Atomic Transaction". Transactions for such a database are generally not able to perform multiple operations. By default, all write operations are performed smoothly. Use the Writeconcern parameter to fine-tune this. Availability ofThe cap theorem asserts that "consistency" (consistency), "availability" (availability), and "Partition tolerance" (Partition tolerance) can only have two. The document database attempts to use the master-slave data replication technology to enhance usability. Multiple nodes maintain the same data, and even if the primary node fails, the client can still get the data. Application code generally does not need to detect whether the master node is available. MONGODB implements replication through the replica set to provide a high degree of availability. Query Functionvarious document databases provide different query capabilities. Couchdb can be queried through views: the materialized view or dynamic view (equivalent to a view in a relational database, regardless of materialization) enables complex document queries. If the query request is more than one, do not process the query request every time Scalabilitythe term "extended" here refers to adding nodes to or modifying the contents of a database without migrating it to a larger computer. Here we don't talk about how to get applications to handle more load, and what we care about is the capabilities of the database itself to improve load handling. Adding more "read slave nodes" directs all read operations to the slave node, which expands the database's ability to respond to frequent reads. Applicable casesEvent Logging (in an enterprise solution, many different applications need to log events.) If the type of data that the event captures is constantly changing, you should use a document database, a content management system, and a blogging platform that can be used to manage user reviews, user registrations, user configurations, and web-oriented documents. ) website analysis and real-time analysis (page views, independent visitors), e-commerce applications. non-applicable occasionscomplex transactions that contain multiple operations (the document database is not suitable for performing cross-document atomic operations, while document databases such as RAVENDB actually support such operations), and the query continuously changes the aggregation structure.
NoSQL Data Model detailed (ii) document model