[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 <<a href="mailto:doanduyhai@gmail.com">doanduyhai@gmail.com</a>> \
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 'uuid'.</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 \
'uuid' + 'key' 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, "Qi Li" <<a href="mailto:ken.liqi@gmail.com" \
target="_blank">ken.liqi@gmail.com</a>> a écrit :<br> ><br>
> Thanks Jack.<br>
><br>
> 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.<br> \
><br> > there are 2 scenarios to query.<br>
> 1. Query for value, it can be any one from value1 to valueN. The query criteria \
will be 'uuid'.<br> > 2. Query for the Double in mapValue. The query \
criteria will be 'uuid' + 'key' in mapValue.<br> ><br>
> Thanks for your help.<br>
><br>
> Ken<br>
><br>
> On Thu, Jan 28, 2016 at 11:22 PM, Jack Krupansky <<a \
href="mailto:jack.krupansky@gmail.com" \
target="_blank">jack.krupansky@gmail.com</a>> wrote:<br> >><br>
>> 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> \
>><br> >> -- Jack Krupansky<br>
>><br>
>> On Thu, Jan 28, 2016 at 5:51 PM, Qi Li <<a \
href="mailto:ken.liqi@gmail.com" target="_blank">ken.liqi@gmail.com</a>> \
wrote:<br> >>><br>
>>> Hi all,<br>
>>><br>
>>> I've found something in Internet, but still want to consult with \
your expertise.<br> >>><br>
>>> I'm designing a table, the object model will be like,<br>
>>> class Data{<br>
>>> String uuid; //partition key<br>
>>> String value1; <br>
>>> String value2;<br>
>>> ...<br>
>>> String valueN;<br>
>>> Map<String, Double> mapValues;<br>
>>> }<br>
>>><br>
>>><br>
>>> 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,<br> >>><br>
>>> create table Data (<br>
>>> text uuid;<br>
>>> text value1;<br>
>>> text value2;<br>
>>> ...<br>
>>> text valueN;<br>
>>> text mapKey;<br>
>>> Double mapValue;<br>
>>> primary key(key, mapKey, value1, value2, ..., valueN);<br>
>>> );<br>
>>><br>
>>> 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?<br> >>><br>
>>> Thanks for your help.<br>
>>><br>
>>> -- <br>
>>> Ken Li<br>
>><br>
>><br>
><br>
><br>
><br>
> -- <br>
> 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