2010-03-19 64 views
10

我希望有人能够帮助我建议使用nosql数据库Apache Cassandra实现的合适数据模型。比我更需要它在高负载和大量数据下工作。为现有模式建议Cassandra数据模型

简体我有3种类型的对象:

  • 产品
  • 标签
  • ProductTag

产品:

key - string key 
name - string 
.... - some other fields 

标签:

key - string key 
name - unique tag words 

ProductTag:

product_key - foreign key referring to product 
tag_key - foreign key referring to tag 
rating - this is rating of tag for this product 

每个产品可具有0或许多标签。标签可以分配给1个或许多产品。就关系型数据库而言,意味着产品和标签之间的关系是多对多的。

“评分”的值经常更新为“非常”。

我需要运行以下查询

  • 通过按键选择对象
  • 产品选择标签通过等级等级product_key下令
  • 通过标记顺序选择产品
  • 更新评级, tag_key

最重要的是让这些查询在大量数据上真快,考虑到评级不断更新。

回答

2

事情是这样的:

Products : { // Column Family 
    productA : { //Row key 
     name: 'The name of the product' // column 
     price: 33.55 // column 
     tags : 'fun, toy' // column 
    } 
} 

ProductTag : { // Column Family 
    fun : { //Row key 
     timeuuid_1 : productA // column 
     timeuuid_2 : productB // column 
    }, 
    toy : { //Row key 
     timeuuid_3 : productA // column 
    } 
} 

UPDATE
入住这Model to store biggest score

+0

有关列出的等级有序的产品标签是什么?或按产品评级排列标签列出产品? 这样的查询需要同时使用2个索引才能生效 – 2010-03-19 21:07:41

+0

这很有道理。感谢您的链接!我正在考虑的另一个想法是使用外部工具,如狮身人面像搜索或可能lucandra选择按评级排序的对象。 Sphinx全文搜索适用于此类任务,但不支持索引的“实时”更新。 – 2010-03-21 13:59:09