0

Can I create a column in cassandra , which is dynamic and can be queried ,

For example ,

A customer can have 1 to n addresses ,

Where each address can be referred like ADDRESS1 (some address) , ADDRES2(some address), ADDRESS3(some address)... ADDRESSN

how can i represent this in cassandra , where i should be able to query a customer or address on particular address also.

Please advise.

  • Just use your customerid da the partition key and address numbers as clustering key. May be you can have an id for each address too if you need. – Ananth Apr 25 '14 at 02:55

1 Answers1

0

first you create column family with comparator type UTF8Type

create column family customerAddress 
with column_type = 'Standard'
and comparator = 'UTF8Type'
and default_validation_class = 'UTF8Type'
and key_validation_class = 'UTF8Type';

and your representation look like this

customerAddress

RowKey: customerId
=> (name=ADDRESS1, value=(some address) , timestamp=1396344612290000)
=> (name=ADDRESS2, value=(some address) , timestamp=1396344612290000)
=> (name=ADDRESS3, value=(some address) , timestamp=1396344612290000)
=> (name=ADDRESS4, value=(some address) , timestamp=1396344612290000)
......
......
=> (name=ADDRESSN, value=(some address) , timestamp=1396344612290000)
Gabber
  • 7,169
  • 3
  • 32
  • 46