views:

498

answers:

1

Hello guys!

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.

+2  A: 

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

rodrigoap
What about listing product tags ordered by rating? Or listing products by a tag ordered by rating?Such query would require use of 2 indexes at the same time to be effective
Andriy Bohdan
It makes sense. Thanks for the link! Another idea i'm considering is to use external tools like sphinx search or maybe lucandra to select objects ordered by rating. Sphinx full text search works good for such tasks, but it doesn't support "real-time" updates of index.
Andriy Bohdan