You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Roshni Rajagopal <Ro...@wal-mart.com> on 2012/08/24 14:15:50 UTC

Data Modeling- another question

Hi,

Suppose I have a column family to associate a user to a dynamic list of items. I want to store 5-10 key  information about the item, & no specific sorting requirements are there.
I have two options

A) use composite columns
UserId1 : {
 <itemid1>:<Name> = Betty Crocker,
 <itemid1>:<Descr> = Cake
<itemid1>:<Qty> = 5
 <itemid2>:<Name> = Nutella,
 <itemid2>:<Descr> = Choc spread
<itemid2>:<Qty> = 15
}

B) use a json with the data
UserId1 : {
 <itemid1> = {name: Betty Crocker,descr: Cake, Qty: 5},
 <itemid2> ={name: Nutella,descr: Choc spread, Qty: 15}
}

Which do you suggest would be better?


Regards,
Roshni

This email and any files transmitted with it are confidential and intended solely for the individual or entity to whom they are addressed. If you have received this email in error destroy it immediately. *** Walmart Confidential ***

Re: Data Modeling- another question

Posted by samal <sa...@gmail.com>.
yes, you are right, it depend on use cases.
I suggested it is a better choice not only choice. JSON will be better if
any filed change re-write whole data without reading.
I tend to use JSON more, where my data does not change or very rarely, Like
storing demoralized JSON data for analytic purpose.
I prefer CF and [:scoped] method for frequently updating filed.
{
this.user.cart.category.p1.name:''
this.user.cart.category.p1.unit:''
this.user.cart.category.p1.desc:''
this.user.cart.category.p2.name:''
this.user.cart.category.p2.unit:''
this.user.cart.category.p2.desc:''
}

Yes you are right, Its really about understating app data and its behavior,
not JSON or column, according to that designing DM.

On Tue, Aug 28, 2012 at 12:20 PM, Guy Incognito <dn...@gmail.com> wrote:

>  i would respectfully disagree, what you have said is true but it really
> depends on the use case.
>
> 1) do you expect to be doing updates to individual fields of an item, or
> will you always update all fields at once?  if you are doing separate
> updates then the first is definitely easier to handle updates.
> 2) do you expect to do paging of the list?  this will be easier with the
> json approach, as in the first your item may span across a page boundary -
> not an insurmountable problem by any means, but more complicated
> nonetheless.  this is not
> an issue obviously if all your items have the same number of fields.
> 3) do you expect to read or delete multiple items individually?  you may
> have to do multiple reads/deletes of a row if the items are not adjacent to
> each other as you cannot do 'disjoint' slices of columns at the moment.
> with the json approach you can just specify individual columns and you're
> done.  again this is less of an issue if items have a known set of fields,
> but your list of columns to read/delete may get quite large fairly quickly
>
> the first is definitely better if you want to update individual fields,
> read-then-write is not a good idea in cassandra.  but it is more
> complicated for most usage scenarios, so you have to work out if you really
> need the extra flexibility.
>
>
> On 24/08/2012 13:54, samal wrote:
>
> First is better choice, each filed can be updated separately(write only).
> Second you have to take care json yourself (read first-modify-then write).
>
> On Fri, Aug 24, 2012 at 5:45 PM, Roshni Rajagopal <
> Roshni.Rajagopal@wal-mart.com> wrote:
>
>> Hi,
>>
>> Suppose I have a column family to associate a user to a dynamic list of
>> items. I want to store 5-10 key  information about the item, & no specific
>> sorting requirements are there.
>> I have two options
>>
>> A) use composite columns
>> UserId1 : {
>>  <itemid1>:<Name> = Betty Crocker,
>>  <itemid1>:<Descr> = Cake
>> <itemid1>:<Qty> = 5
>>  <itemid2>:<Name> = Nutella,
>>  <itemid2>:<Descr> = Choc spread
>> <itemid2>:<Qty> = 15
>> }
>>
>> B) use a json with the data
>> UserId1 : {
>>  <itemid1> = {name: Betty Crocker,descr: Cake, Qty: 5},
>>  <itemid2> ={name: Nutella,descr: Choc spread, Qty: 15}
>> }
>>
>> Which do you suggest would be better?
>>
>>
>> Regards,
>> Roshni
>>
>> This email and any files transmitted with it are confidential and
>> intended solely for the individual or entity to whom they are addressed. If
>> you have received this email in error destroy it immediately. *** Walmart
>> Confidential ***
>>
>
>
>

Re: Data Modeling- another question

Posted by Guy Incognito <dn...@gmail.com>.
i would respectfully disagree, what you have said is true but it really 
depends on the use case.

1) do you expect to be doing updates to individual fields of an item, or 
will you always update all fields at once?  if you are doing separate 
updates then the first is definitely easier to handle updates.
2) do you expect to do paging of the list?  this will be easier with the 
json approach, as in the first your item may span across a page boundary 
- not an insurmountable problem by any means, but more complicated 
nonetheless.  this is not
an issue obviously if all your items have the same number of fields.
3) do you expect to read or delete multiple items individually? you may 
have to do multiple reads/deletes of a row if the items are not adjacent 
to each other as you cannot do 'disjoint' slices of columns at the 
moment.  with the json approach you can just specify individual columns 
and you're done.  again this is less of an issue if items have a known 
set of fields, but your list of columns to read/delete may get quite 
large fairly quickly

the first is definitely better if you want to update individual fields, 
read-then-write is not a good idea in cassandra.  but it is more 
complicated for most usage scenarios, so you have to work out if you 
really need the extra flexibility.

On 24/08/2012 13:54, samal wrote:
> First is better choice, each filed can be updated separately(write only).
> Second you have to take care json yourself (read first-modify-then write).
>
> On Fri, Aug 24, 2012 at 5:45 PM, Roshni Rajagopal 
> <Roshni.Rajagopal@wal-mart.com <ma...@wal-mart.com>> 
> wrote:
>
>     Hi,
>
>     Suppose I have a column family to associate a user to a dynamic
>     list of items. I want to store 5-10 key  information about the
>     item, & no specific sorting requirements are there.
>     I have two options
>
>     A) use composite columns
>     UserId1 : {
>      <itemid1>:<Name> = Betty Crocker,
>      <itemid1>:<Descr> = Cake
>     <itemid1>:<Qty> = 5
>      <itemid2>:<Name> = Nutella,
>      <itemid2>:<Descr> = Choc spread
>     <itemid2>:<Qty> = 15
>     }
>
>     B) use a json with the data
>     UserId1 : {
>      <itemid1> = {name: Betty Crocker,descr: Cake, Qty: 5},
>      <itemid2> ={name: Nutella,descr: Choc spread, Qty: 15}
>     }
>
>     Which do you suggest would be better?
>
>
>     Regards,
>     Roshni
>
>     This email and any files transmitted with it are confidential and
>     intended solely for the individual or entity to whom they are
>     addressed. If you have received this email in error destroy it
>     immediately. *** Walmart Confidential ***
>
>


Re: Data Modeling- another question

Posted by samal <sa...@gmail.com>.
First is better choice, each filed can be updated separately(write only).
Second you have to take care json yourself (read first-modify-then write).

On Fri, Aug 24, 2012 at 5:45 PM, Roshni Rajagopal <
Roshni.Rajagopal@wal-mart.com> wrote:

> Hi,
>
> Suppose I have a column family to associate a user to a dynamic list of
> items. I want to store 5-10 key  information about the item, & no specific
> sorting requirements are there.
> I have two options
>
> A) use composite columns
> UserId1 : {
>  <itemid1>:<Name> = Betty Crocker,
>  <itemid1>:<Descr> = Cake
> <itemid1>:<Qty> = 5
>  <itemid2>:<Name> = Nutella,
>  <itemid2>:<Descr> = Choc spread
> <itemid2>:<Qty> = 15
> }
>
> B) use a json with the data
> UserId1 : {
>  <itemid1> = {name: Betty Crocker,descr: Cake, Qty: 5},
>  <itemid2> ={name: Nutella,descr: Choc spread, Qty: 15}
> }
>
> Which do you suggest would be better?
>
>
> Regards,
> Roshni
>
> This email and any files transmitted with it are confidential and intended
> solely for the individual or entity to whom they are addressed. If you have
> received this email in error destroy it immediately. *** Walmart
> Confidential ***
>