Basic questions about getting started with MongoDB

Source: Internet
Author: User
Tags mongodb collection

1.MongoDB is a document-oriented database, what are the benefits of document-oriented?

Unlike relational databases, a document-oriented database does not have a "line" concept, but rather a "document" concept, because documents can embed documents and arrays, so a document can use a record to represent complex hierarchies.

In addition, document-oriented is no longer a pre-defined mode, usually the relational database design database in the first design of the structure of the table, document-oriented database is not required, because there is no need for fixed mode, so it is easy to add deleted fields, it is easier to display complex hierarchical relationship.

What features are available in 2.MongoDB for us to use?

MongoDB provides indexing, replication, sharding, and rich query statements, noting that MongoDB does not have connection (join) and complex multi-line transactional capabilities.

3.MongoDB is not only type-sensitive, but case-sensitive.

{"Foo": 3} {"Foo": "3"} {"Foo": 3} {"Foo": 3}

4.MongoDB documents cannot have duplicate keys

{"First": "Hello World", "first": "Hello Mongo"}


If you can place any document in a 5.MongoDB collection, why use multiple collections?

Easy to distinguish a wide variety of documents.

It is much faster to query multiple collections separately.

Documents of the same type are placed in a collection and the data is more concentrated

Placing only one type of document in a collection makes it more efficient to index the collection.

Keep database name in 6.MongoDb

Admin

This is an administrator database, that is, the root database, if you add a user to this database, the user will automatically get all the database permissions, and some special server-side commands can only be run from the admin database, such as listing all databases or shutting down the server.

Local

This database can never be copied, this is a local database, and all local collections on a single server can be stored in this database.

Config

The Shard information is stored in the config database.

Data types in 7.MongoDB

NULL, Boolean, numeric, string, regular expression, array, inline document, object ID, binary data, arbitrary JavaScript code, JavaScript in date class

8. Purpose of the Mongorc.js file

If some scripts are used frequently, you can add them to mongorc.js, which will run automatically when you start the shell. One of the most common uses of mongorc.js is to remove the more dangerous shell helper functions, as follows:

var no = function () {      print ("Not no my watch."); Disable Delete Database Db.dropdatabase = DB.prototype.dropDatabase = no;//Suppress collection DBCollection.prototype.drop = no;// Prohibit Delete index DBCollection.prototype.dropIndex = no;
These methods do not protect the database from malicious users, only to prevent the misuse of their own hands.


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Basic questions about getting started with MongoDB

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.