Search code examples
cassandrasuper-columns

Cassandra and supercolumns


I have next question: is it possible to create column family in cassandra that would look like this below and how to define it's structure:

Users = {   //CF
     AlexS : { //row key
         Address : { //supercolumn
               state: "NJ",
               country: "US",
               phone : { //super column
                    zip: "00283",
                    number : { // supercolumn
                       home: "23756511",
                       mobile : "23756512"
                    } 
               } 
         }
     }   
}

Solution

  • Nested super column within super column for four levels? As far as I know, that is not possible. Because you need to specify by referencing which column family of that current insertion you want it to be. Consider the following, you can have define top level column family to be of type column family super. Then you can have multiple super-columns within this super column family and this supercolumns will have multiple column=value pairs those are called as subcolumns. For example,

    list Users;    
    Using default limit of 100
    -------------------
    RowKey: AlexS
    => (super_column=Address,
         (column=country, value=US, timestamp=1331614891360000)
         (column=state, value=NJ, timestamp=1331614891355000))
    => (super_column=number,
         (column=home, value=23756511, timestamp=1331614891406000)
         (column=mobile, value=23756512, timestamp=1331614891406001))
    => (super_column=phone,
         (column=zip, value=00283, timestamp=1331614891396000))
    
    1 Row Returned.
    Elapsed time: 21 msec(s).