[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cassandra-user
Subject:    Re: Wide row in Cassandra
From:       Qi Li <ken.liqi () gmail ! com>
Date:       2016-01-29 7:42:49
Message-ID: CAKW_qge1PmZDXaoZQvzvk9=a=BfzNP6fr+b56FohnZmV19N5vA () mail ! gmail ! com
[Download RAW message or body]

static column is exactly what I want!

Thank you Duyhai!

On Fri, 29 Jan 2016 07:22 DuyHai Doan <doanduyhai@gmail.com> wrote:

> This data model should do the job
>
> Create table Data (
>    text uuid;
>    text value1 static;
>    text value2 static;
>    ...
>    text valueN static;
>    text mapKey;
>    Double mapValue;
>    primary key(key, mapKey);
> );
>
> Warning, value1... valueN being static, there will be a 1:1 relationship
> between them and the partition key uuid.
>
> 1.Query for value, it can be any one from value1 to valueN. The query
> criteria will be 'uuid'.
>
> SELECT value1,..., valueN FROM data
> WHERE partition = uuid
>
> 2. Query for the Double in mapValue. The query criteria will be 'uuid' +
> 'key' in mapValue
>
> SELECT mapValue FROM data WHERE partition = uuid AND mapKey = double
>
>
> Le 29 janv. 2016 07:51, "Qi Li" <ken.liqi@gmail.com> a écrit :
> >
> > Thanks Jack.
> >
> > the columns to be used for query will be 'uuid' and 'key' in mapValues.
> For value1 to valueN, and Double in mapValues will be merely return.
> >
> > there are 2 scenarios to query.
> > 1. Query for value, it can be any one from value1 to valueN. The query
> criteria will be 'uuid'.
> > 2. Query for the Double in mapValue. The query criteria will be 'uuid' +
> 'key' in mapValue.
> >
> > Thanks for your help.
> >
> > Ken
> >
> > On Thu, Jan 28, 2016 at 11:22 PM, Jack Krupansky <
> jack.krupansky@gmail.com> wrote:
> >>
> >> As usual, the first step should be to example your queries and use them
> as the guide to data modeling. So... how do you need to access the data?
> What columns do you need to be able to query on vs. merely return? What
> data needs to be accessed at the same time? What data does not need to be
> accessed at the same time?
> >>
> >> -- Jack Krupansky
> >>
> >> On Thu, Jan 28, 2016 at 5:51 PM, Qi Li <ken.liqi@gmail.com> wrote:
> >>>
> >>> Hi all,
> >>>
> >>> I've found something in Internet, but still want to consult with your
> expertise.
> >>>
> >>> I'm designing a table, the object model will be like,
> >>> class Data{
> >>>      String uuid;        //partition key
> >>>      String value1;
> >>>      String value2;
> >>>      ...
> >>>      String valueN;
> >>>      Map<String, Double> mapValues;
> >>> }
> >>>
> >>>
> >>> For one Data object, I would like it to be saved into one wide row in
> C*, that means the mapValues will be extended as dynamic columns. AFAIK, I
> can put the mapValues' key into Cluster column, then C* will use the wide
> row to save the data. Then I would use 'uuid' as partition key, and mapKey
> into cluster key. My question is for the other columns : value1 to valueN,
> shall I put them into ClusterKey too? like below,
> >>>
> >>> create table Data (
> >>>    text uuid;
> >>>    text value1;
> >>>    text value2;
> >>>    ...
> >>>    text valueN;
> >>>    text mapKey;
> >>>    Double mapValue;
> >>>    primary key(key, mapKey, value1, value2, ..., valueN);
> >>> );
> >>>
> >>> The reason I put them into cluster keys is I don't want value1 to
> valueN are saved duplicated each time when the mapKey is created. For
> example, the mapValues can have 100 entries, I don't want value1 to valueN
> are saved 100 times, I only want them saved 1 time together with the
> partition key. Is this correct?
> >>>
> >>> Thanks for your help.
> >>>
> >>> --
> >>> Ken Li
> >>
> >>
> >
> >
> >
> > --
> > Ken Li
>

[Attachment #3 (text/html)]

static column is exactly what I want!   <div><br></div><div>Thank you \
Duyhai!<br><br><div class="gmail_quote"><div dir="ltr">On Fri, 29 Jan 2016 07:22  \
DuyHai Doan &lt;<a href="mailto:doanduyhai@gmail.com">doanduyhai@gmail.com</a>&gt; \
wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">This data model should \
do the job </p> <p dir="ltr">Create table Data (<br>
     text uuid;<br>
     text value1 static;<br>
     text value2 static;<br>
     ...<br>
     text valueN static;<br>
     text mapKey;<br>
     Double mapValue;<br>
     primary key(key, mapKey);<br>
);</p>
<p dir="ltr">Warning, value1... valueN being static, there will be a 1:1 relationship \
between them and the partition key uuid.<br></p> <p dir="ltr">1.Query for value, it \
can be any one from value1 to valueN. The query criteria will be &#39;uuid&#39;.</p> \
<p dir="ltr">SELECT value1,..., valueN FROM data<br> WHERE partition = uuid</p>
<p dir="ltr">2. Query for the Double in mapValue. The query criteria will be \
&#39;uuid&#39; + &#39;key&#39; in mapValue </p> <p dir="ltr">SELECT mapValue FROM \
data WHERE partition = uuid AND mapKey = double <br></p><p dir="ltr">  <br>
Le  29 janv. 2016 07:51, &quot;Qi Li&quot; &lt;<a href="mailto:ken.liqi@gmail.com" \
target="_blank">ken.liqi@gmail.com</a>&gt; a écrit  :<br> &gt;<br>
&gt; Thanks Jack.<br>
&gt;<br>
&gt; the columns to be used for query will be &#39;uuid&#39; and &#39;key&#39; in \
mapValues. For value1 to valueN, and Double in mapValues will be merely return.<br> \
&gt;<br> &gt; there are 2 scenarios to query.<br>
&gt; 1. Query for value, it can be any one from value1 to valueN. The query criteria \
will be &#39;uuid&#39;.<br> &gt; 2. Query for the Double in mapValue. The query \
criteria will be &#39;uuid&#39; + &#39;key&#39; in mapValue.<br> &gt;<br>
&gt; Thanks for your help.<br>
&gt;<br>
&gt; Ken<br>
&gt;<br>
&gt; On Thu, Jan 28, 2016 at 11:22 PM, Jack Krupansky &lt;<a \
href="mailto:jack.krupansky@gmail.com" \
target="_blank">jack.krupansky@gmail.com</a>&gt; wrote:<br> &gt;&gt;<br>
&gt;&gt; As usual, the first step should be to example your queries and use them as \
the guide to data modeling. So... how do you need to access the data? What columns do \
you need to be able to query on vs. merely return? What data needs to be accessed at \
the same time? What data does not need to be accessed at the same time?<br> \
&gt;&gt;<br> &gt;&gt; -- Jack Krupansky<br>
&gt;&gt;<br>
&gt;&gt; On Thu, Jan 28, 2016 at 5:51 PM, Qi Li &lt;<a \
href="mailto:ken.liqi@gmail.com" target="_blank">ken.liqi@gmail.com</a>&gt; \
wrote:<br> &gt;&gt;&gt;<br>
&gt;&gt;&gt; Hi all,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; I&#39;ve found something in Internet, but still want to consult with \
your expertise.<br> &gt;&gt;&gt;<br>
&gt;&gt;&gt; I&#39;m designing a table, the object model will be like,<br>
&gt;&gt;&gt; class Data{<br>
&gt;&gt;&gt;         String uuid;            //partition key<br>
&gt;&gt;&gt;         String value1;     <br>
&gt;&gt;&gt;         String value2;<br>
&gt;&gt;&gt;         ...<br>
&gt;&gt;&gt;         String valueN;<br>
&gt;&gt;&gt;         Map&lt;String, Double&gt; mapValues;<br>
&gt;&gt;&gt; }<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; For one Data object, I would like it to be saved into one wide row in \
C*, that means the mapValues will be extended as dynamic columns. AFAIK, I can put \
the mapValues&#39; key into Cluster column, then C* will use the wide row to save the \
data. Then I would use &#39;uuid&#39; as partition key, and mapKey into cluster key. \
My question is for the other columns : value1 to valueN, shall I put them into \
ClusterKey too? like below,<br> &gt;&gt;&gt;<br>
&gt;&gt;&gt; create table Data (<br>
&gt;&gt;&gt;      text uuid;<br>
&gt;&gt;&gt;      text value1;<br>
&gt;&gt;&gt;      text value2;<br>
&gt;&gt;&gt;      ...<br>
&gt;&gt;&gt;      text valueN;<br>
&gt;&gt;&gt;      text mapKey;<br>
&gt;&gt;&gt;      Double mapValue;<br>
&gt;&gt;&gt;      primary key(key, mapKey, value1, value2, ..., valueN);<br>
&gt;&gt;&gt; );<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; The reason I put them into cluster keys is I don&#39;t want value1 to \
valueN are saved duplicated each time when the mapKey is created. For example, the \
mapValues can have 100 entries, I don&#39;t want value1 to valueN are saved 100 \
times, I only want them saved 1 time together with the partition key. Is this \
correct?<br> &gt;&gt;&gt;<br>
&gt;&gt;&gt; Thanks for your help.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; -- <br>
&gt;&gt;&gt; Ken Li<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; -- <br>
&gt; Ken Li</p></blockquote></div></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic