简体   繁体   English

SQL 与 noSQL 构建示例

[英]SQL vs noSQL build examples

我可以有一个我应该在 sql 数据库上构建的应用程序类型列表和一个我应该在 nosql 数据库上构建的应用程序列表吗?

There is no list and the real answer IMHO is the classic "It Depends".没有列表,恕我直言,真正的答案是经典的“它取决于”。

In very loose terms, financial applications where consistency is critical would be an example of something not suitable for NoSQL - in that case, ACID is crucial.....BASE would not be suitable (Basically Available Soft state Eventually consistent).用非常宽松的术语来说,一致性至关重要的金融应用程序将是不适合 NoSQL 的一个例子 - 在这种情况下,ACID 至关重要......BASE 将不适合(基本可用软状态最终一致)。

You really need to understand what NoSQL has to offer vs RDBMS, and the tradeoffs in order to know whether it is suitable for a given scenario.您确实需要了解 NoSQL 与 RDBMS 相比必须提供什么,以及权衡,以便了解它是否适​​合给定场景。

When chosing there is no one-stop fit all solutions选择时没有一站式适合所有解决方案

USE SQL When:在以下情况下使用 SQL:

1. We need to ensure ACID compliance. For Huge enterprise applications like eCommerce or Banking applications it is a preferred option.
2. When Data is consistent.

USE Nosql When何时使用 Nosql

1. Want to store large volumes of data that has very little structure or no structure.
2. Rapid development
3. Horizontal scaling possible ie. your database can split across multiple servers.

More about Non-Relational databases :有关非关系数据库的更多信息:

  1. Key-Value Stores :- stores data in key value pairs, Eg.键值存储:- 将数据存储在键值对中,例如。 Redis, Voldemort etc Redis、伏地魔等
  2. Document Databases:- Data store based on a documentid.文档数据库:- 基于文档 ID 的数据存储。 Eg.例如。 CouchDB, MongoDB etc CouchDB、MongoDB 等
  3. Wide-Column Databases :- Stores data in terms of columnar rather than rows Eg: Cassandra, HBase etc宽列数据库:- 以列而非行的形式存储数据,例如:Cassandra、HBase 等
  4. Graph Databases:- Data represented in terms of links and nodes.图数据库:- 用链接和节点表示的数据。 Eg.例如。 Neo4J, InfiniteGraph Neo4J,无限图

Example: Key Value based data Eg: Cassandra, Mongodb "Eg: For Id=123 Value = { ""name"":""Lalith Swarna"", ""address"":{ ""street"":""Gachibowli Road"", ""city"":""Hyderabad"" }, ""company"":""ais"", ""role"":""Specialist"" }"示例:基于键值的数据 例如:Cassandra, Mongodb "Eg: For Id=123 Value = { ""name"":""Lalith Swarna"", ""address"":{ ""street"":""Gachibowli Road"", ""city"":""Hyderabad"" }, ""company"":""ais"", ""role"":""Specialist"" }"

Advantages:优点:

1. Insert/Retrieval : simple key based w/o any joins Schema is easily
changeable 
2. Built for scaling: data is partitioned internally Built for metrics/analytics/aggregation : Eg Average age, total sal etc

Disadvantages:缺点:

1. NOT built for updates(ACID-AtomicityConsistency)  is not followed to update it does Delete and update.
2. Read times are lower than Sql eg: retrieve Age 30  takes all the json and filters the age. 
3. Foreign key constraint not straighforward. 
4. Joins are hard, have to run through everyblock of data find the relevant dataid then join with other table.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM