Cassandra数据模型

编程入门 行业动态 更新时间:2024-10-26 02:29:22
本文介绍了Cassandra数据模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用POC来展示Cassandra的工作原理。我以Digg为例。我想创建一个数据模型,让我:

I'm working on a POC to showcase how Cassandra works. I took Digg as an example. I wanted to create a data model that'll let me:

1)添加链接 2)添加一个链接到用户收藏列表。 3)为链接附加预定标签

1) Add links 2) Add a link to a user favorite list. 3) Attached predetermined tags to links

我想出了两个列族:

  • 链接

  • Links

    • url是关键字
      • id(a generated uuid)
      • 用户(添加者)
      • favCount $ b
      • upCount(不喜欢该用户的用户数)
      • downCount(不喜欢该用户的用户数)
      • url is the key
        • id (a generated uuid)
        • user (who added it)
        • favCount (no of users who favorited the link)
        • upCount (no of users who liked it)
        • downCount (no of users who disliked it)

        UserFavs

        • b $ b
          • id(与用户已收藏的许多ID相同)

          这适用于上面的要求#1和#2,但是当我来到#3它变得更加棘手。我可以添加像java,languages,architecture这样的标签作为列名,在Links列族中有空值。但是查询将需要很长时间,让我们说如果我找到所有标记在java下的链接。

          This works fine for requirements #1 and #2 above, but when I come to #3 it gets trickier. I can add tags like 'java', 'languages', 'architecture' as column names with empty values in the Links column family. But querying will take a long time, let's say if I were to find out all the links that were tagged under 'java'.

          任何人都可以提出一些如何实现的想法。

          Can anyone throw some ideas of how this can be implemented.

          如果我不清楚

          感谢您,Kumar

          推荐答案

          您可以创建辅助索引,即以标签为关键字的列族。每行包含该特定标记的所有链接。注意,这可能导致非常宽的行(即具有许多列),其中每一行将被存储在单个cassandra节点上。

          You could create a secondary index, i.e. a column family keyed on tag. Each row contains all the links for that particular tag. Note that this may result in very wide rows (i.e. with many columns) each of which will be stored on a single cassandra node. You might want a scheme to split these up if they get very large.

          请参阅 www.datastax/docs/0.7/data_model/cfs_as_indexes

          或 pkghosh.wordpress/2011/03/02/cassandra -secondary-index-patterns /

          或google cassandra二级索引

  • 更多推荐

    Cassandra数据模型

    本文发布于:2023-11-04 05:47:21,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1557108.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:数据模型   Cassandra

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!