1. Why study?
project needs, the company needs to dig up valuable information from the previous log records and purchase information, the data volume of large structure complex;
The requirements of the project decide to solve the problems of high-concurrency and read-write of database, efficient storage and access of massive data, high scalability and high availability.
MongoDB (unstructured database) can handle not only structured data, but also unstructured data (text, images, hypermedia, and so on). It breaks through the constraint that the relational database structure definition is not easy to change and the data is fixed long, which has the superiority of relational database in processing continuous information and unstructured information.
MongoDB Advantages: Large data volume high performance, easy to expand, high availability, easy to achieve the storage of large data volume; the perfect Java API, the storage format json, is very good for java,js, it is easy to handle, clear version control, very active community.
relational database is not good at: write large amount of data, field is not fixed, table structure change, simple query needs to return the result quickly;
MongoDB is widely used in major internet companies, covering a wide range of applications and simple to use.
What are the features of 2.MongoDB?
Document-oriented storage: BSON
for collection storage: Data that stores object types easily.
Powerful query function: Support rich query expressions. Using a JSON-style tag, you can query objects and arrays embedded in the document.
full Query functionality: Full-index support includes inline objects and arrays. The query optimizer generates an efficient query plan.
Mode freedom: The keys in the collection do not require consistency, and the key values do not require a consistent data type. Do not know any structure definition of it
Replication (master/slave replication/replica set) and automatic failover: For fault recovery, read extension; MONGO database supports data replication between servers, support for master- slave mode, and replication between servers
shard (Auto shard): For load balancing, write extension. Supports a level of database cluster, adding additional machines dynamically
GRIDSFS: Avoid the file system to the directory to do the number of files limit. does not produce disk fragmentation
Support ruby,python,java,c++ and other multi-languages, multi-platform
Query monitoring: Monitoring tools for analyzing database operational performance
Caching services: Caching relational database data to reduce data pressure
Automatically process fragmentation
Third, MongoDB storage of binary data in the database solution?
Two: The first is to convert files to binary data into MongoDB, as in the case of storing normal data, and the second uses GRIDFS
First: Read the contents of the file, then plug into the Bson.binary.Binary object, and finally write to the database as usual, get the file as simple as usual, find the data, and then write the binary content to the file;
The second is if a large file can be used Gridfs
Gridfs will divide the file into several blocks to store, each block size defaults to 256K, so, if it is a small file, do not use GRIDFS to store, otherwise it will waste space, Gridfs is a distributed file system on top of MongoDB, MongoDB's sharding and replication mechanisms can be used because MongoDB allocates data space in 2GB, so GRIDFS does not produce disk fragmentation.
This article is from the Apple blog, so be sure to keep this source http://59465168.blog.51cto.com/5268021/1947902
Why use MongoDB?