If you are familiar with MySQL or PostgreSQL for example, SQL databases allow you to add and retrieve data using a specific language, called SQL, that looks like this:
例如,如果您熟悉MySQL或PostgreSQL,则SQL数据库允许您使用一种称为SQL的特定语言来添加和检索数据,如下所示:
SELECT * FROM cars
INSERT INTO cars VALUES (fiesta, 2010)
SQL is rather old, being born in 1986, and it’s a battle-tested technology.
SQL很老,诞生于1986年,它是一项经过考验的技术。
Under the NoSQL umbrella we put all those databases that do not use the SQL language for querying the data.
在NoSQL的保护下,我们放置了所有不使用SQL语言查询数据的数据库。
MongoDB falls under this umbrella.
MongoDB受此保护。
MongoDB is a document database. Instead of storing records, we store objects (called documents).
MongoDB是一个文档数据库 。 我们没有存储记录,而是存储对象(称为document )。
How does this differ from a SQL database? Tables in a SQL database are flat and static, they can host data but limited to what the original intent was (you can’t add a column dynamically) and to store complex data you need to create many tables and link the data in each table, following the relational databases common practices (like foreign keys, column types, etc).
这与SQL数据库有何不同? SQL数据库中的表是平面的和静态的 ,它们可以承载数据,但限于原始意图(您不能动态添加列),并且要存储复杂的数据,需要创建许多表并在每个表中链接数据,遵循关系数据库的常规做法(例如外键,列类型等)。
In MongoDB you can store any object without having to worry about the particular fields that compose this object and how to store them. You tell MongoDB to store that object.
在MongoDB中,您可以存储任何对象,而不必担心组成该对象的特定字段以及如何存储它们。 您告诉MongoDB存储该对象。
With MongoDB, you don’t need to learn another language to interact with the data: you just call the JavaScript methods it exposes and that’s it (of course you can interact with it using other languages as well).
使用MongoDB,您无需学习另一种语言即可与数据进行交互:您只需调用它公开JavaScript方法即可(当然,您也可以使用其他语言与之交互)。
Data is stored in a format similar to JSON, but enhanced to allow storing more than just basic data types.
数据以类似于JSON的格式存储,但经过增强后可以存储的不仅仅是基本数据类型。
I hope this gives you a brief overview of the key differences between SQL databases and MongoDB.
我希望这能给您简要概述SQL数据库和MongoDB之间的主要区别。