From a circle of friends,
One of the main types of NoSQL is document-type NoSQL, such as MongoDB, which stores data using a JSON structure, without having to define a record structure in advance, and to freely add an item in a deleted record, very flexible
With this scenario, you can see the convenience of NoSQL very well.
Scene Contact List
How SQL is implemented
We need to define the table structure of the contact first, such as
ID (primary key ID)
Title (caption)
FirstName (surname)
LastName (name)
Gender (gender)
Telephone (telephone)
Email (email)
Address1 (address 1)
Address2 (Address 2)
City (urban)
Now that there's a new problem, a lot of people have multiple phone numbers, like 2 phone numbers, 1 work calls, or something, and for extensibility, we need to create a separate phone list, so we don't care how many phones the contacts have.
CONTACT_ID (Contact ID)
Name (e.g. landline number, work cell phone, etc.)
Number (phone numbers)
Similarly, the mailbox, address also has this problem, but also in accordance with the above way, the new email form and the Address table
But soon, the new problem arises, and we need to record the contact's social account, his preferences ..., we have to create a variety of tables to correspond
This causes the database administrator and the developer to be a little bit troublesome, needs to change the database structure frequently, needs many tables the association query and so on
It's a little laborious to use SQL to record this fragmented data.
How NoSQL is implemented
Each contact information is a JSON data, and the contact list is a collection of JSON data stored in a document
For example
{
Name: ["Billy", "Bob"],
Company: "Corp",
JobTitle: "Data Management",
Telephone: {
Mobile: "9876543210",
Work: "2244668800"
},
Email: {
Personal: "[email protected]",
Work: "[email protected]"
},
Address: {
Home: {
Line: "Ten non-existent Street",
City: "Nowhere",
Country: "Australia"
}
},
Twitter: ' @bobsfakeaccount ',
Note: "Don ' t trust this guy"
}
For example, this contact has one more phone number and it's good to add a new data item directly to the telephone, for example
Telephone: {
Home: "0123456789",
Mobile: "9876543210",
Work: "2244668800"
}
For example, now you need to record the user's number, directly in the contact's JSON to add a new number of data items can be
In this scenario, you can see that using NoSQL in some scenarios is more convenient, and NoSQL is mature enough to consider how to apply it in practice.
This scenario is better for using NoSQL