Data Structure: Simply put, 1. document is the most basic data organization form in MongoDB. Each document is organized in Key-Value (Key-Value Pair) mode. For example:
Data Structure: Simply put, 1. document is the most basic data organization form in MongoDB. Each document is organized in Key-Value (Key-Value Pair) mode. For example:
Data structure:
1. document is the most basic data organization form in MongoDB. Each document is organized in Key-Value (Key-Value Pair) mode.
For example:
{"Greeting": "Hello World! "}
2. A document can contain multiple Key-Value combinations. Each Value can be of different types, such as String, Integer, and List.
For example:
1. {"name": "huangz ",
2. "sex": "male ",
3. "age": 20}
3. Organize multiple documents to form a collection ). If you compare a document to a row in a relational database, the set is a table in the database ).
In relational databases (such as MySQL), there is always the same row in the same database table. For example, you have a student table with id, name, and ,, age, class, and grade rows, the entire student can only have the same rows.
However, in MongoDB, the content format can be very casual. In a collection, store multiple documents with different keys and different types. For example, you can store them in a student set, there are documents in the following format:
In this student set, every document is not required to have the same Key and type.
1 .{
2. "name": "huangz ",
3. "age": 20,
4. "sex": "male"
5 .}
6.
7 .{
8. "name": "jack ",
9. "class": 3,
10. "grade": 3
11 .}
To sum up, MongoDB organizes data as follows:
Key-Value Pair> document> set> Database
In addition, in MongoDB (excluding GridFS), the size of a single document cannot exceed 4 mb (version> = 1.7 is 16 MB ).
The Key follows the following rules:
The naming rules of a set are similar to those of a document. Remember that
The system set is retained.
In addition, ". "Number is allowed in the set, and they are used as subcollections. For example, if you have a blog set, you can use a blog. title, blog. content or blog. author helps you better organize collections.
By organizing multiple sets, a database is formed ). A single MongoDB instance can use multiple databases. Each database operates independently and has independent permissions. The data of each database is stored in different files separately.