datamodel - Cassandra Data Model - Multiple composite columns -
i trying model next info model in cassandra:
business - primary key : businessid
has many reviews - primary key : reviewid - review 1 - body - rating - review 2 - body - rating , on has address - state - city - zip has business hours - mon hours - tuesday hours , on has offers - offer1 - offer2 , on
i want able extract info using 1 query, i.e. want store in 1 business row. how can this? essentially, have many kid entities want store along parent business entity. understand composite keys, can have 1 composite key (ex) businessid:reviewid model reviews), how store these entities in 1 single row efficiently retrieve business details in 1 query.
my sec question regarding updates. suppose 1 of these entities (reviews) gets updated frequently. other entities remain static. advisable separate reviews giant business row, or can update reviews without getting entire business row in memory?
you can accomplish you're trying using traditional schema-less thrift-based query model. info model this:
key: reviewid { review:1:body = "" review:1:rating = 1 review:2:body = "" review:2:rating = 1 address:1:city = "" address:1:state = "" address:1:zip = "" hours:1:monday = "" hours:1:tuesday = "" offer:1:[fieldname] = "" offer:2:[fieldname] = "" }
the schema composite(utf8type, integertype, utf8type)
whatever key type matches reviewid , whatever value type matches values (can bytes if have disparate types).
cassandra datamodel
No comments:
Post a Comment