MongoDB Learning History

Source: Internet
Author: User

RDBMS vs NoSQL
Rdbms
Real-time consistent transaction multi-table federated query

Nosql
Simple and convenient to extend better performance
-key-value pair storage, column storage, document storage, graphics database
(* * * *)-final consistency, not ACID properties
-Unstructured and unpredictable data
-Cap theorem
-High performance, high availability and scalability

Advantages:
-High Scalability
-Distributed computing
-Low cost
-Architecture flexibility, semi-structured data
-No complicated relationship.
Disadvantages:
-No standardization
-Limited query function (so far)
-final agreement is not intuitive program

In the era of big data, SQL has been less able to meet demand.
Mongodb:
NoSQL is not just a product of SQL, distributed, between relational and non-relational databases, but is the richest and most like relational database in non-relational databases.
relational databases Follow acid rules: Atomicity consistency Independence persistence
Mongo
Db.shutdownserver ()
Kill-15
Db.dropdatabase ()

Basic syntax:
Increase

By deleting
Db.collection_xiaoya.remove ({c:1}) deletes all data with C of 1, does not allow incoming null conditions, and removes all information that meets the criteria.
Db.collection_xiaoya.drop () deletes the entire table.
Change
Update updates only the topmost one, in order to prevent the update from operating incorrectly.
Check

Index: (significantly faster query speed)
Inquire:
Db.collection_xiaoya.getIndexes ()
Create:
Db.collection_xiaoya.ensureIndex ({x:1})
Classification:
ID index key-value key is the name of the field value can be either 1 or-1 to indicate the direction of the index.
Single-key index (established on a field such as String/number/date, not automatically created)
Multi-key index (values have multiple records, such as arrays)
Composite index: When we have not only one query condition, we need to build a composite index.
Expired index: An index that expires after a certain period of time. When the index expires, the corresponding data is deleted. (60 seconds minimum)
Full-text index (text index): Create full-text searchable indexes on strings and string arrays
Location index (/mo mo, etc.):

Collection:

Copy set:

Sharding:

Data equalization:

Under Linux server:
There are no spaces for Bin/mongo.
Show DBS
Use DBXXX (automatically created without a library)
Show tables

Show collections
Db. Collection name. Find (default is all queries)
Db. Collection name. Find (). Count ()
For loop insertion
Db. Collection name. Find (). Skip (3). Limit (2). Sort ({x:1})//filter 3 data display 2 bar by X
Db.order_raw_data.findOne (); This thing

Db.order_report_info.remove ({"Extitemid": "18120968"})//with curly braces OH
Writeresult ({"Nremoved": 3})//description deleted 3!!

Java Operation MongoDB:
Monodb drive with the ability to convert JSON into DBObject objects, plus Google's Gson, can be implemented to save ordinary objects to MongoDB.
















MongoDB Learning History

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.