Android Development Learning-------MongoDB Database Simple Understanding

Source: Internet
Author: User

First of all, what is MongoDB?

MongoDB is a product between a relational database and a non-relational database, and is the most versatile and most like relational database in a non-relational database.

MongoDB is a database based on Distributed file storage .

NoSQL (not just SQL) is a generic term for a database management system that differs from a traditional relational database. There is no need to follow the acid rules of relational databases,

For ultra-large-scale data storage, these types of data storage do not require a fixed pattern and can scale horizontally without unnecessary operations.

************************************************************************************

Comparison of relational and non-relational types:

Rdbms
-Highly organized structured data
-Structured Query Language (SQL) (SQL)
-Data and relationships are stored in separate tables.
-Data manipulation language, data definition language
-Strict consistency
-Basic services

Nosql
-represents more than just SQL
-No declarative query language
-No pre-defined pattern
-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

NoSQL emphasizes the advantages of key-value Stores and the documentation database , rather than simply opposing the RDBMS.

The pros/cons of NoSQL

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

*****************************************************************************

MongoDB is the document storage type, the document storage is generally stored in a JSON -like format, the data structure is composed of key-value (key=>value) pairs, the stored content is document-type.

This also gives you the opportunity to index certain fields and implement certain functions of the relational database.

******************************************************************************

MongoDB Installation configuration:

This own Baidu, a lot of tutorials, https://jingyan.baidu.com/article/e52e36156372ce40c60c5194.html

Http://www.runoob.com/mongodb/mongodb-window-install.html

After the test is installed successfully, install the visualizer Robomongo.

Anyway, I was in the installation of configuration and connection when encountered a lot of pits, then did not record, in short, Baidu can solve the problem.

*******************************************************************************

Terminology corresponding to the RDBMS and MongoDB:

    1. The key/value pairs in the document are ordered.
    2. The values in the document can be not only strings in double quotes, but also several other data types (even the entire embedded document).
    3. MongoDB distinguishes between type and case.
    4. MongoDB documents cannot have duplicate keys .
    5. The key of the document is a string . In addition to a few exceptions, keys can use any UTF-8 character.

**************************************************************************

After understanding the basic concepts above, the most important is crud operations.

Reference https://www.cnblogs.com/garinzhang/p/mongoDB_basic_usage.html

Show DBS: Display Database list

Show Collections: Displays a collection in the current database (similar to a table in a relational database)

Use DB name: Toggle the current database-switch local to admin

Db.dropdatabase (); Delete current Database

Db.getmongo (); View the link machine address of the current DB

To create a new collection explicitly:

db.createcollection (< Name>, {capped: <BOOLEAN>, Autoindexid: <BOOLEAN>, size: <NUMBER>, Max: <NUMBER> StorageEngine: <DOCUMENT> Validator: <DOCUMENT>, Validationlevel: <STRING> Validationaction: <STRING>, Indexoptiondefaults: <document>})        

This command creates a collection of up to 5,000 documents named "User" with a maximum storage space of 5m.

Add data: There are no fixed columns, whichever is the added data.

Modify data: Equivalent to update user set Name= ' Harry ' where age = 33;

Delete data:

Query data:

1:select * from user;

2:select distict name from user; Filter out the same data in name.

Filter data based on columns.

3:select * from user where Age = 15;

4:select * from user where >15;

5:select * from user where <22;

6:select * from user where age >= 25;

7:select * from user where age <= 25;

8:

9:select * from the user where name like '%%uh '; Fuzzy query

10:select name, age from user;

Of course name can also be used with true or false, as in the case of Ture River Name:1 effect, if False is to exclude name, display column information other than name.

11:select name, age from user where >25; Queries the data for the specified column.

12: In ascending order of age

Descending row

13:select * from user where name = ' hehe ' and age = ' 85 '

14:select Top 2 * from user; Query the first two data

15: Query 2 after the data

16:

Android Development Learning-------MongoDB Database Simple Understanding

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.