【问题标题】:follower/following in cassandra卡桑德拉的追随者/追随者
【发布时间】:2017-12-17 21:50:38
【问题描述】:

我们正在 Cassandra 中设计一个类似 Twitter 的追随者/关注者,并发现了类似的东西

从这里https://www.slideshare.net/jaykumarpatel/cassandra-at-ebay-13920376/13-Data_Model_simplified_13

所以我认为 ItemLike 是一张桌子? itemid1=>(userid1, userid2...) 是表中的一行? 你认为这个 ItemLike 表的 create table 是什么?

【问题讨论】:

    标签: cassandra cassandra-2.0 cassandra-2.1 cassandra-3.0


    【解决方案1】:

    是的,ItemLike 是一张桌子

    ItemLike 表的架构将是 Like :

    CREATE TABLE itemlike(
        itemid bigint,
        userid bigint,
        timeuuid timeuuid,
        PRIMARY KEY(itemid, userid)
    ); 
    

    幻灯片的图片就是上表的内部结构。

    让我们插入一些数据:

     itemid | userid | timeuuid
    --------+--------+--------------------------------------
          2 |    100 | f172e3c0-67a6-11e7-8e08-371a840aa4bb
          2 |    103 | eaf31240-67a6-11e7-8e08-371a840aa4bb
          1 |    100 | d92f7e90-67a6-11e7-8e08-371a840aa4bb
    

    cassandra 内部会存储如下数据:

    --------------------------------------------------------------------------------------|
    |    |             100:timeuuid              |            103:timeuuid                | 
    |    +---------------------------------------+----------------------------------------|
    |2   | f172e3c0-67a6-11e7-8e08-371a840aa4bb  |  eaf31240-67a6-11e7-8e08-371a840aa4bb  |
    --------------------------------------------------------------------------------------|
    
    ---------------------------------------------|
    |    |             100:timeuuid              |
    |    +---------------------------------------|
    |1   | d92f7e90-67a6-11e7-8e08-371a840aa4bb  |
    ---------------------------------------------|
    

    【讨论】:

    • 所以我只是insert into itemlike(itemid, userid) values(100, 1000)insert into itemlike(itemid, userid) values(100, 1001) 等等?我以为这张图片有点像insert into itemlike(itemid, userid1, userid2...) values(100, 1000, 1001, 1002.....)
    • 是的,您只需插入 insert into itemlike(itemid, userid) values(100, 1000)。 cassandra 在内部存储幻灯片图像等数据
    猜你喜欢
    • 2019-07-03
    • 1970-01-01
    • 1970-01-01
    • 2017-12-08
    • 2021-10-09
    • 1970-01-01
    • 2021-06-13
    • 1970-01-01
    • 2018-07-12
    相关资源
    最近更新 更多