在 Cassandra 中建模 M:M 关系的替代方法是什么? [英] What are the alternative ways to model M:M relations in Cassandra?

查看:19
本文介绍了在 Cassandra 中建模 M:M 关系的替代方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑需要在 Cassandra 数据存储中表示的 M:M 关系.

Consider a M:M relation that needs to be represented in a Cassandra data store.

有哪些 M:M 建模选项可用?对于每一个选择,什么时候更喜欢?您在 Cassandra 驱动的项目中做出了哪些 M:M 建模选择?

What M:M modeling options are available? For each alternative, when is it to prefer? What M:M modeling choices have you made in your Cassandra powered projects?

推荐答案

与使用 rdbms 的方式使用连接表不同,您将拥有一个 ColumnFamily,其中包含每个 X 的一行以及与之关联的 Y 列表,然后是一个 CF,其中包含每个 Y 的行和与其关联的每个 X 的列表.

Instead of using a join table the way you would with an rdbms, you would have one ColumnFamily containing a row for each X and a list of Ys associated with it, then a CF containing a row for each Y and a list of each X associated with it.

如果事实证明你并不真正关心查询这些方向之一,那么只保留你关心的 CF.

If it turns out you don't really care about querying one of those directions then only keep the CF that you do care about.

这篇关于在 Cassandra 中建模 M:M 关系的替代方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆