开发者

Suggest Cassandra data model for an existing schema

I hope there's someone who can help me suggest a suitable data model to be implemented using nosql database Apache Cassandra. More of than I need it to work under high loads and large amounts of data.

Simplified I have 3 types of objects:

  • Product
  • Tag
  • ProductTag

Product:

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

Tag:

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

Each product may have 0 or many tags. Tag may be assigned to 1 or many products. Means relation between products and tags is many-to-many in terms of relational databases.

Value of "rating" is updated "very" often.

I need to be run the following queries

  • Select objects by keys
  • Select tags for product ordered by rating
  • Select products by tag order by rating
  • Update rating by product_key 开发者_如何学编程and tag_key

The most important is to make these queries really fast on large amounts of data, considering that rating is constantly updated.


Something like this:

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
Check this Model to store biggest score

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜