什么时候使用键值数据存储,而不是更传统的关系数据库?

时间:2022-10-03 22:42:40

When would one choose a key-value data store over a relational DB? What considerations go into deciding one or the other? When is mix of both the best route? Please provide examples if you can.

什么时候会选择键值数据存储而不是关系数据库?在决定一个或另一个问题时需要考虑什么?什么时候是两种最佳路线的混合?如果可以,请提供一些例子。

5 个解决方案

#1


1  

In my experience, if you're even asking the question whether to use traditional vs esoteric practices, then go traditional. While esoteric practices are sexy, challenging, and fun, 99.999% of applications call for a traditional approach.

根据我的经验,如果你问的是是否要使用传统的和深奥的方法,那就去传统的。虽然深奥的实践是性感的、有挑战性的、有趣的,但是99.999%的应用程序需要传统的方法。

With regards to relational vs KV, the question you should be asking is:

关于关系vs KV,你应该问的问题是:

Why would I not want to use a relational model for this scenario: ...

为什么我不想在这种情况下使用关系模型:……

Since you have not described the scenario, it's impossible for anyone to tell you why you shouldn't use it. The "catch all" reason for KV is scalability, which isn't a problem now. Do you know the rules of optimization?

由于您还没有描述这个场景,所以任何人都不可能告诉您为什么不应该使用它。KV的“捕获所有”原因是可扩展性,这现在不是问题。你知道最优化的规则吗?

  1. Don't do it.
  2. 不要这样做。
  3. (for experts only) Don't do it now.
  4. (对专家来说)现在不要这样做。

KV is a highly optimized solution to scalability that will most likely be completely unecessary for your application.

KV是一种高度优化的可扩展性解决方案,对于您的应用程序来说,它可能是完全不必要的。

#2


15  

Key-value, heirarchical, map-reduce, or graph database systems are much closer to implementation strategies, they are heavily tied to the physical representation. The primary reason to choose one of these is if there is a compelling performance argument and it fits your data processing strategy very closely. Beware, ad-hoc queries are usually not practical for these systems, and you're better off deciding on your queries ahead of time.

键值、继承、map-reduce或graph数据库系统更接近实现策略,它们与物理表示密切相关。选择其中之一的主要原因是,如果存在一个引人注目的性能参数,并且它非常适合您的数据处理策略。注意,临时查询对于这些系统通常不实用,最好提前决定查询。

Relational database systems try to separate the logical, business-oriented model from the underlying physical representation and processing strategies. This separation is imperfect, but still quite good. Relational systems are great for handling facts and extracting reliable information from collections of facts. Relational systems are also great at ad-hoc queries, which the other systems are notoriously bad at. That's a great fit in the business world and many other places. That's why relational systems are so prevalent.

关系数据库系统试图将面向业务的逻辑模型与底层的物理表示和处理策略分离开来。这种分离是不完美的,但仍然很好。关系系统对于处理事实和从事实集合中提取可靠信息非常有用。关系系统在特别查询方面也做得很好,而其他系统在这方面做得很差。这在商业世界和许多其他地方都很合适。这就是关系系统如此流行的原因。

If it's a business application, a relational system is almost always the answer. For other systems, it's probably the answer. If you have more of a data processing problem, like some pipeline of things that need to happen and you have massive amounts of data, and you know all of your queries up front, another system may be right for you.

如果它是一个业务应用程序,那么关系系统几乎总是答案。对于其他系统,这可能是答案。如果你有更多的数据处理问题,比如一些需要发生的事情,你有大量的数据,你知道所有的查询,另一个系统可能适合你。

#3


4  

If your data is simply a list of things and you can derive a unique identifier for each item, then a KVS is a good match. They are close implementations of the simple data structures we learned in freshman computer science and do not allow for complex relationships.

如果您的数据只是一个列表,并且您可以为每个项目派生一个惟一的标识符,那么KVS是一个很好的匹配。它们是我们在大一计算机科学中学习到的简单数据结构的紧密实现,不考虑复杂的关系。

A simple test: can you represent your data and all of its relationships as a linked list or hash table? If yes, a KVS may work. If no, you need an RDB.

一个简单的测试:能否将数据及其所有关系表示为链表或散列表?如果是的话,kv可能有用。如果没有,你需要一个RDB。

You still need to find a KVS that will work in your environment. Support for KVSes, even the major ones, is nowhere near what it is for, say, PostgreSQL and MySQL/MariaDB.

您仍然需要找到一个在您的环境中工作的kv。对kvse的支持,即使是主要的kvse,也远不及PostgreSQL和MySQL/MariaDB。

#4


0  

A traditional relational database has problems scaling beyond a point. Where that point is depends a bit on what you are trying to do.

传统的关系数据库存在扩展超过一点的问题。这个点在哪里取决于你要做什么。

All (most?) of the suppliers of cloud computing are providing key-value data stores.

云计算供应商的所有(大部分)都提供了键值数据存储。

However, if you have a reasonably sized application with a complicated data structure, then the support that you get from using a relational database can reduce your development costs.

但是,如果您有一个大小合理、数据结构复杂的应用程序,那么使用关系数据库所获得的支持可以降低开发成本。

#5


0  

IMO, Key value pair (e.g. NoSQL databases) works best when the underlying data is unstructured, unpredictable, or changing often. If you don't have structured data, a relational database is going to be more trouble than its worth because you will need to make lots of schema changes and/or jump through hoops to conform your data to the structure.

在我看来,当底层数据是非结构化、不可预测或经常变化时,关键值对(例如NoSQL数据库)最有效。如果您没有结构化数据,那么关系数据库将会比它的价值更麻烦,因为您将需要进行大量的模式更改和/或跳转,以使您的数据符合结构。

KVP / JSON / NoSql is great because changes to the data structure do not require completely refactoring the data model. Adding a field to your data object is simply a matter of adding it to the data. The other side of the coin is there are fewer constraints and validation checks in a KVP / Nosql database than a relational database so your data might get messy.

KVP / JSON / NoSql非常棒,因为对数据结构的更改不需要完全重构数据模型。将字段添加到数据对象只是将其添加到数据的问题。另一方面,KVP / Nosql数据库中的约束和验证检查比关系数据库更少,因此数据可能会变得混乱。

There are performance and space saving benefits for relational data models. Normalized relational data can make understanding and validating the data easier because there are table key relationships and constraints to help you out.

关系数据模型具有性能和节省空间的优点。规范化关系数据可以使理解和验证数据更容易,因为有表键关系和约束可以帮助您解决问题。

One of the worst patterns i've seen is trying to have it both ways. Trying to put a key-value pair into a relational database is often a recipe for disaster. I would recommend using the technology that suits your data foremost.

我所见过的最糟糕的一种模式是尝试两种方式。尝试将键-值对放入关系数据库通常会导致灾难。我建议您使用最适合您的数据的技术。

#1


1  

In my experience, if you're even asking the question whether to use traditional vs esoteric practices, then go traditional. While esoteric practices are sexy, challenging, and fun, 99.999% of applications call for a traditional approach.

根据我的经验,如果你问的是是否要使用传统的和深奥的方法,那就去传统的。虽然深奥的实践是性感的、有挑战性的、有趣的,但是99.999%的应用程序需要传统的方法。

With regards to relational vs KV, the question you should be asking is:

关于关系vs KV,你应该问的问题是:

Why would I not want to use a relational model for this scenario: ...

为什么我不想在这种情况下使用关系模型:……

Since you have not described the scenario, it's impossible for anyone to tell you why you shouldn't use it. The "catch all" reason for KV is scalability, which isn't a problem now. Do you know the rules of optimization?

由于您还没有描述这个场景,所以任何人都不可能告诉您为什么不应该使用它。KV的“捕获所有”原因是可扩展性,这现在不是问题。你知道最优化的规则吗?

  1. Don't do it.
  2. 不要这样做。
  3. (for experts only) Don't do it now.
  4. (对专家来说)现在不要这样做。

KV is a highly optimized solution to scalability that will most likely be completely unecessary for your application.

KV是一种高度优化的可扩展性解决方案,对于您的应用程序来说,它可能是完全不必要的。

#2


15  

Key-value, heirarchical, map-reduce, or graph database systems are much closer to implementation strategies, they are heavily tied to the physical representation. The primary reason to choose one of these is if there is a compelling performance argument and it fits your data processing strategy very closely. Beware, ad-hoc queries are usually not practical for these systems, and you're better off deciding on your queries ahead of time.

键值、继承、map-reduce或graph数据库系统更接近实现策略,它们与物理表示密切相关。选择其中之一的主要原因是,如果存在一个引人注目的性能参数,并且它非常适合您的数据处理策略。注意,临时查询对于这些系统通常不实用,最好提前决定查询。

Relational database systems try to separate the logical, business-oriented model from the underlying physical representation and processing strategies. This separation is imperfect, but still quite good. Relational systems are great for handling facts and extracting reliable information from collections of facts. Relational systems are also great at ad-hoc queries, which the other systems are notoriously bad at. That's a great fit in the business world and many other places. That's why relational systems are so prevalent.

关系数据库系统试图将面向业务的逻辑模型与底层的物理表示和处理策略分离开来。这种分离是不完美的,但仍然很好。关系系统对于处理事实和从事实集合中提取可靠信息非常有用。关系系统在特别查询方面也做得很好,而其他系统在这方面做得很差。这在商业世界和许多其他地方都很合适。这就是关系系统如此流行的原因。

If it's a business application, a relational system is almost always the answer. For other systems, it's probably the answer. If you have more of a data processing problem, like some pipeline of things that need to happen and you have massive amounts of data, and you know all of your queries up front, another system may be right for you.

如果它是一个业务应用程序,那么关系系统几乎总是答案。对于其他系统,这可能是答案。如果你有更多的数据处理问题,比如一些需要发生的事情,你有大量的数据,你知道所有的查询,另一个系统可能适合你。

#3


4  

If your data is simply a list of things and you can derive a unique identifier for each item, then a KVS is a good match. They are close implementations of the simple data structures we learned in freshman computer science and do not allow for complex relationships.

如果您的数据只是一个列表,并且您可以为每个项目派生一个惟一的标识符,那么KVS是一个很好的匹配。它们是我们在大一计算机科学中学习到的简单数据结构的紧密实现,不考虑复杂的关系。

A simple test: can you represent your data and all of its relationships as a linked list or hash table? If yes, a KVS may work. If no, you need an RDB.

一个简单的测试:能否将数据及其所有关系表示为链表或散列表?如果是的话,kv可能有用。如果没有,你需要一个RDB。

You still need to find a KVS that will work in your environment. Support for KVSes, even the major ones, is nowhere near what it is for, say, PostgreSQL and MySQL/MariaDB.

您仍然需要找到一个在您的环境中工作的kv。对kvse的支持,即使是主要的kvse,也远不及PostgreSQL和MySQL/MariaDB。

#4


0  

A traditional relational database has problems scaling beyond a point. Where that point is depends a bit on what you are trying to do.

传统的关系数据库存在扩展超过一点的问题。这个点在哪里取决于你要做什么。

All (most?) of the suppliers of cloud computing are providing key-value data stores.

云计算供应商的所有(大部分)都提供了键值数据存储。

However, if you have a reasonably sized application with a complicated data structure, then the support that you get from using a relational database can reduce your development costs.

但是,如果您有一个大小合理、数据结构复杂的应用程序,那么使用关系数据库所获得的支持可以降低开发成本。

#5


0  

IMO, Key value pair (e.g. NoSQL databases) works best when the underlying data is unstructured, unpredictable, or changing often. If you don't have structured data, a relational database is going to be more trouble than its worth because you will need to make lots of schema changes and/or jump through hoops to conform your data to the structure.

在我看来,当底层数据是非结构化、不可预测或经常变化时,关键值对(例如NoSQL数据库)最有效。如果您没有结构化数据,那么关系数据库将会比它的价值更麻烦,因为您将需要进行大量的模式更改和/或跳转,以使您的数据符合结构。

KVP / JSON / NoSql is great because changes to the data structure do not require completely refactoring the data model. Adding a field to your data object is simply a matter of adding it to the data. The other side of the coin is there are fewer constraints and validation checks in a KVP / Nosql database than a relational database so your data might get messy.

KVP / JSON / NoSql非常棒,因为对数据结构的更改不需要完全重构数据模型。将字段添加到数据对象只是将其添加到数据的问题。另一方面,KVP / Nosql数据库中的约束和验证检查比关系数据库更少,因此数据可能会变得混乱。

There are performance and space saving benefits for relational data models. Normalized relational data can make understanding and validating the data easier because there are table key relationships and constraints to help you out.

关系数据模型具有性能和节省空间的优点。规范化关系数据可以使理解和验证数据更容易,因为有表键关系和约束可以帮助您解决问题。

One of the worst patterns i've seen is trying to have it both ways. Trying to put a key-value pair into a relational database is often a recipe for disaster. I would recommend using the technology that suits your data foremost.

我所见过的最糟糕的一种模式是尝试两种方式。尝试将键-值对放入关系数据库通常会导致灾难。我建议您使用最适合您的数据的技术。