结合使用关系数据库和键值存储

时间:2022-06-27 12:33:53

The requirements for the project I'm working seem to point to using both a relational database (e.g. postgre, MySQL) in combination with a key-value store (e.g. HBase, Cassandra). Our data almost breaks nicely into one of the two data models with the exception of a small amount of interdependence.

我正在工作的项目的要求似乎指向使用关系数据库(例如postgre,MySQL)和键值存储(例如HBase,Cassandra)。除少量相互依赖外,我们的数据几乎可以很好地分解为两种数据模型中的一种。

This is not an attempt to cram a relational database into a key-value store; they are independent of each other.

这不是将关系数据库塞入键值存储的尝试;他们彼此独立。

Are there any serious reasons to not do this?

有没有严重的理由不这样做?

3 个解决方案

#1


I work in SQL DBMS territory, so take that bias into account, but...

我在SQL DBMS领域工作,所以考虑到这种偏见,但......

As with Shiraz Bhaiji, I worry about the "except for a small amount of interdependence". There are a number of things to think about, the answers to which will help you determine what to do.

和Shiraz Bhaiji一样,我担心“除了少量的相互依存”。有许多事情需要考虑,其中的答案将帮助您确定要做什么。

  • What happens if something goes wrong with the interdependence? (Customers lose money - then you need to use a DBMS throughout; you lose money - probably the same; someone gets reported as having 3045 points when they really have 3046 - maybe it doesn't matter.)
  • 如果相互依赖出现问题,会发生什么? (客户赔钱 - 然后你需要在整个过程中使用DBMS;你输了钱 - 可​​能是相同的;有人报告说他们确实有3046分时有3045分 - 也许没关系。)

  • How hard is it to fix up the 'mess' when something goes wrong?
  • 当出现问题时,修复“乱七八糟”有多难?

  • How much of the work is on the key-value store and how much is on the DBMS?
  • 关键值存储有多少工作,DBMS有多少工作?

  • Can the interdependence be removed by moving some stuff from key-value store to DBMS?
  • 可以通过将一些东西从键值存储区移动到DBMS来消除相互依赖性吗?

  • How slow is the DBMS when used as a key-value store? (Are you sure there's no way to bring it close enough to parity?)
  • DBMS用作键值存储时有多慢? (你确定没有办法让它足够接*价?)

  • What happens in disaster recovery scenarios? Synchronized backups?
  • 灾难恢复方案中会发生什么?同步备份?

If you have adequate answers to these and related questions, then it is OK to go with the mixed setup - you've thought it through, weighed the risks, formed a judgement, and it is reasonable to go ahead. If you don't have answers, get them.

如果您对这些问题和相关问题有足够的答案,那么可以选择混合设置 - 您已经考虑过,权衡风险,形成判断,并且继续进行是合理的。如果你没有答案,那就去买吧。

#2


It should work fine.

它应该工作正常。

There are a couple of things you need to be aware of / watch out for:

您需要注意/注意以下几点:

  • Your program is now responsible for the data consistency between the stores, not the relational model.
  • 您的程序现在负责存储之间的数据一致性,而不是关系模型。

  • Depending on your technology you may or may not have transactions that span the data stores. Here you might have to program some manual clean up work in the case of a failure.
  • 根据您的技术,您可能会或可能不会拥有跨数据存储的事务。在这里,您可能需要在发生故障时编写一些手动清理工作。

#3


When you say key-value store are you meaning like in a session or a cache type of implementation? There are always reasons to do such things...reading from and writing to a database is generally your most resource intensive operation. More details?

当你说键值存储是你在会话或缓存类型的实现中的含义?总是有理由做这些事情......读取和写入数据库通常是最耗费资源的操作。更多细节?

#1


I work in SQL DBMS territory, so take that bias into account, but...

我在SQL DBMS领域工作,所以考虑到这种偏见,但......

As with Shiraz Bhaiji, I worry about the "except for a small amount of interdependence". There are a number of things to think about, the answers to which will help you determine what to do.

和Shiraz Bhaiji一样,我担心“除了少量的相互依存”。有许多事情需要考虑,其中的答案将帮助您确定要做什么。

  • What happens if something goes wrong with the interdependence? (Customers lose money - then you need to use a DBMS throughout; you lose money - probably the same; someone gets reported as having 3045 points when they really have 3046 - maybe it doesn't matter.)
  • 如果相互依赖出现问题,会发生什么? (客户赔钱 - 然后你需要在整个过程中使用DBMS;你输了钱 - 可​​能是相同的;有人报告说他们确实有3046分时有3045分 - 也许没关系。)

  • How hard is it to fix up the 'mess' when something goes wrong?
  • 当出现问题时,修复“乱七八糟”有多难?

  • How much of the work is on the key-value store and how much is on the DBMS?
  • 关键值存储有多少工作,DBMS有多少工作?

  • Can the interdependence be removed by moving some stuff from key-value store to DBMS?
  • 可以通过将一些东西从键值存储区移动到DBMS来消除相互依赖性吗?

  • How slow is the DBMS when used as a key-value store? (Are you sure there's no way to bring it close enough to parity?)
  • DBMS用作键值存储时有多慢? (你确定没有办法让它足够接*价?)

  • What happens in disaster recovery scenarios? Synchronized backups?
  • 灾难恢复方案中会发生什么?同步备份?

If you have adequate answers to these and related questions, then it is OK to go with the mixed setup - you've thought it through, weighed the risks, formed a judgement, and it is reasonable to go ahead. If you don't have answers, get them.

如果您对这些问题和相关问题有足够的答案,那么可以选择混合设置 - 您已经考虑过,权衡风险,形成判断,并且继续进行是合理的。如果你没有答案,那就去买吧。

#2


It should work fine.

它应该工作正常。

There are a couple of things you need to be aware of / watch out for:

您需要注意/注意以下几点:

  • Your program is now responsible for the data consistency between the stores, not the relational model.
  • 您的程序现在负责存储之间的数据一致性,而不是关系模型。

  • Depending on your technology you may or may not have transactions that span the data stores. Here you might have to program some manual clean up work in the case of a failure.
  • 根据您的技术,您可能会或可能不会拥有跨数据存储的事务。在这里,您可能需要在发生故障时编写一些手动清理工作。

#3


When you say key-value store are you meaning like in a session or a cache type of implementation? There are always reasons to do such things...reading from and writing to a database is generally your most resource intensive operation. More details?

当你说键值存储是你在会话或缓存类型的实现中的含义?总是有理由做这些事情......读取和写入数据库通常是最耗费资源的操作。更多细节?