> How does approach B work in CQL. Can we read/write a JSON
> easily in CQL?  Can we extract a field from a JSON in CQL
> or would that need to be done  via the client code?

Via client code. Support for this is much the same as support for JSON CLOBs in an RDBMS.

Approach A is better if you are going to update attributes as it avoids reads before writes, which can damage throughput.

A consideration for A are read times when the user has a high cardinality of <items> resulting in a wide row - in that case reads for an <item> should be tested. Writes tend to be cheap regardless of row size.

Bill

On 19/09/12 13:00, Roshni Rajagopal wrote:
Hi,

There was a conversation on this some time earlier, and to continue it

Suppose I want to associate a user to  an item, and I want to also store
3 commonly used attributes without needing to go to an entity item
column family , I have 2 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}
}

Essentially A is better if one wants to update individual fields , while
B is better if one wants easier paging, reading multiple items at once
in one read. etc. The details are in this discussion thread
http://cassandra-user-incubator-apache-org.3065146.n2.nabble.com/Data-Modeling-another-question-td7581967.html

I had an additional question,
as its being said, that CQL is the direction in which cassandra is
moving, and there's a lot of effort in making CQL the standard,

How does approach B work in CQL. Can we read/write a JSON easily in CQL?
Can we extract a field from a JSON in CQL or would that need to be done
via the client code?

Regards,
Roshni

Reply via email to