1024programmer Java Repository of mongodb, redis, mysql

Repository of mongodb, redis, mysql

MongoDB is a powerful, flexible, and easy-to-extend general-purpose database

MongoDB is written in C++ language and is an open source database system based on distributed file storage.

Under high load conditions, adding more nodes can ensure server performance.

MongoDB aims to provide scalable, high-performance data storage solutions for WEB applications.

MongoDB stores data as a document, and the data structure consists of key-value (key=>value) pairs. MongoDB documents are similar to JSON objects. Field values ​​can contain other documents, arrays, and document arrays .

Features of MongoDB:

1. Ease of use

MongoDB is written in C++ and is an open source database system based on distributed file storage. It is not a relational database. Under high load conditions, add more More nodes can ensure server performance.

MongoDB is a document-oriented database, not a relational database.
 The main reason for not using the relational type is to obtain better scalability.  Of course there are some other benefits. Compared with relational databases, document-oriented databases no longer have "rows"
 The concept is replaced by a more flexible "document" model.  The document-oriented approach is able to work with just one record by embedding documents and arrays in the document
 to represent complex hierarchical relationships, which is consistent with how modern object-oriented language developers view data.
 In addition, there is no longer a predefined schema: the key and value of the document are no longer of fixed type and size
 .  Since there is no fixed schema, it becomes easier to add or remove fields as needed.  Often the development process is accelerated because developers are able to iterate quickly.
 Moreover, experiments are easier to conduct.  Developers can try out a large number of data models and choose the best one.  

2. Easy scalability

The size of application data sets is growing at an incredible rate. As available bandwidth increases and memory prices decrease, even a small-scale application  program, the amount of data that needs to be stored may also be staggeringly large, or even exceed
 This increases the processing power of many databases.  T-level data, which was very rare in the past, is now commonplace.
 As the amount of data that needs to be stored continues to grow, developers are faced with a problem: how to expand the database, which is divided into vertical expansion and horizontal expansion. Vertical expansion is the most labor-saving approach, but the disadvantage is that mainframes are generally very expensive, and
 When the amount of data reaches the physical limit of the machine, no matter how much money you spend, you cannot buy a stronger machine. At this time, horizontal expansion is more appropriate, but another problem caused by horizontal expansion is that there are too many machines that need to be managed.  .
 MongoDB is designed to scale horizontally.  The document-oriented data model makes it easy to split data among multiple servers.  MongoDB can automatically handle data and load across clusters, automatically redistribute documents,
 As well as routing user requests to the correct machine.  This way, developers can focus on writing applications rather than thinking about how to scale.
 If a cluster needs more capacity, just add a new server to the cluster and MongoDB will automatically transfer the existing data to the new server

3. Rich functions

As a general database, MongoDB, in addition to being able to create, read, update and delete data, also provides a series of continuously expanding  unique features
 #1. Index
 Supports general secondary indexes, allows a variety of fast queries, and provides unique indexes, composite indexes, geospatial indexes, and full-text indexes

 #2. Aggregation
 Supports aggregation pipelines, allowing users to create complex collections from simple fragments and automatically optimize them through the database

 #3. Special collection types
 Supports collections with limited existence time, suitable for data that will expire at a certain time, such as sessions.  Similarly, MongoDB also supports fixed-size collections
 , used to save recent data, such as logs

 #4. File storage
 Supports a very easy-to-use protocol for storing large files and file metadata.  MongoDB does not have some features that are common in relational databases.
 Such as chain joins and complex multi-row transactions.  Omit
 These functions are due to architectural considerations, or to obtain better scalability, because these two functions are difficult to implement efficiently in distributed systems

4. Excellent performance

One of the main goals of MongoDB is to provide excellent performance.an>

3. Command line shell

#1. mongo 127.0.0.1:27017/config #Connect to any database config

 #2. mongo --nodb #Do not connect to any database

 #3. After startup, run the new Mongo(hostname) command when needed to connect to the desired mongod:
 > cOnn=new Mongo('127.0.0.1:27017')
 connection to 127.0.0.1:27017
 > db=conn.getDB('admin')
 admin

 #4. helpView help

 #5. Mongo is a simplified Javascript shell that can execute Javascript scripts

4. Basic data types

1. Conceptually, MongoDB documents are similar to Javascript objects, so they can be considered similar to JSON. JSON (http://www.json.org ) is a simple data representation: its specification can be described clearly in just one paragraph (its official website proves this), and it only contains six data types.

2. This has many advantages: easy to understand, easy to parse, and easy to remember. However, on the other hand, because there are only null, Boolean, numbers, strings, There are several data types such as numbers and objects, so the expression ability of JSON has certain limitations.

3. Although these types of JSON are already very expressive, most applications (especially when dealing with databases) still require others. Important types. For example, JSON has no date type, which makes easy date processing annoying. In addition, JSON has only one numeric type and cannot distinguish between floats and integers, let alone 32-bit and 64-bit. Furthermore, JSON Some other generic types, such as regular expressions or functions, cannot be represented.

4. MongoDB adds some other data types while retaining the basic key/value pair characteristics of JSON. Under different programming languages, these types of The exact representation differs slightly. Here’s a description of the other common types supported by MongoDB and how to use them in documents

5. Data type

#1. null: used to represent empty or non-existent fields
 d={'x':null}
 #2. Boolean type: true and false
 d={'x':true,'y'  :false}
 #3. Value
 d={'x':3,'y'  :3.1415926}
 #4. String
 d={'x':'egon'}
 #5. Date
 d={'x':new Date()}
 d.x.getHours()
 #6. Regular expressions
 d={'pattern':/^egon.*?nb$/i}

 Regular expressions are written within //, and the i behind them represents:
 i ignore case
 m multi-line matching pattern
 x ignore unescaped whitespace characters
 s single line matching pattern

 #7. Array
 d={'x':[1,'a  ','v']}

 #8. Embedded documents
 user={'name':'egon','addr':{'country':'China','city':'YT'}}
 user.addr.country

 #9. Object id: It is a 12-byte ID, which is the unique identifier of the document and is immutable
 d={'x':ObjectId()}

View Code

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/repository-of-mongodb-redis-mysql/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索