SQL到MongoDB的映射图表
文章已阅读次
下表介绍了各种SQL术语和概念以及相应的MongoDB术语和概念。
SQL术语/概念 | MongoDB术语/概念 |
---|---|
database | database |
table | collection |
row | document or BSON document |
column | field |
index | index |
table joins | $lookup, 嵌入文档 |
primary key (指定任何唯一的列或列组合作为主键。) | primary key (在MongoDB中,主键自动设置为_id字段。) |
aggregation (e.g. group by) | aggregation pipeline See the SQL to Aggregation Mapping Chart. |
SELECT INTO NEW_TABLE | $out See the SQL to Aggregation Mapping Chart. |
MERGE INTO TABLE | $merge (Available starting in MongoDB 4.2) See the SQL to Aggregation Mapping Chart. |
Transactions | transactions 在许多情况下,非规范化数据模型(嵌入式文档和数组) 将继续是您数据和用例的最佳选择,而不是多文档事务。 也就是说,在许多情况下,对数据进行适当的建模将最 大程度地减少对多文档交易的需求。 |