SQL and NoSQL instructions

Source: Internet
Author: User

In a traditional database,

The format of the database is made up of tables (table), Rows (Row), Fields (field). The table has a fixed structure that specifies
What fields are in each row, defined at the time of creation, and then difficult to modify. The format of the row is the same, by a number of fixed
The fields are composed. Each table may have several fields as indexes (index), some of which have primary keys (primary key),
Used to constrain the data in the table, and a unique key (unique key) to ensure that no duplicate data is stored in the field. Between tables and tables
There may also be mutual constraints, called foreign keys (foreign key). Each query to the database is in the behavior unit, complex
Queries include nested queries, connection queries, and cross-table queries.
A database with these features is called a relational database, and a relational database typically uses a type called SQL
The query Language (structured query Language) is called an interface, and is therefore referred to as a SQL database. Typical number of SQL
It has MySQL, Oracle, Microsoft SQL Server, PostgreSQL, SQLite, and more.


NoSQL was introduced in 1998 as a lightweight, open source, relational database that does not provide SQL functionality.
But now NoSQL is considered not the only SQL abbreviation, mainly refers to the non-relational, distributed, does not provide Acid①
Database System. As its name implies, NoSQL is not designed to replace SQL databases, but
As a supplement, it has its own different areas of adaptation to SQL database. NoSQL is not like SQL database
Have a unified architecture and interface, different NoSQL database systems may be completely different from the inside out.

2. MongoDB
MongoDB is an object database that has no concepts such as tables, rows, or fixed patterns and structures, all
Data is stored as a document. The so-called document is an associative array of objects, its interior is composed of attributes, a
The value of a property may be a number, a string, a date, an array, or even a nested document.

Here is a
Example of a MongoDB document:
{"_id": ObjectId ("4f7fe8432b4a1077a7c551e8"),
"UID": 2004,
"username": "Byvoid",
"Net9": {"nickname": "Byvoid",
"Surname": "Kuo",
"givenname": "Carbo",
"FullName": "Carbo Kuo",
"Emails": ["[Email protected]", "[email protected]"],
"Website": "Http://www.byvoid.com",
"Address": "Zijing, Tsinghua University"}
}
The UID in the above document is an integer attribute, username is a string property, and _id is the identity of the Document object
The ObjectId character, formatted as a specific. NET9 is a nested document whose internal structure is the same as a general document. From
Format to look at the document as JSON, yes, MongoDB data format is Json②, so with JavaScript

①acid is the four characteristics that a transaction (transaction) in a database system must have, namely atomicity (atomicity), consistency (consistency),
Isolation (isolation) and persistence (durability).
② to be precise, MongoDB's data format is BSON (Binary JSON), which is an extension of JSON.

Affinity is strong. The operation of data in Mongodb is in the document, and of course we can modify the document
Part of the property. For a query operation, we only need to specify any one of the properties of the document to be satisfied in the database
All documents of the condition are filtered out. To speed up the query, MongoDB also indexes the document, and the number of SQL
According to the library.

SQL and NoSQL instructions

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.