You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by sat <sa...@gmail.com> on 2016/11/07 00:23:20 UTC

Designing a table in cassandra

Hi,

We are new to Cassandra. For our POC, we tried creating table and inserting
them as JSON and all these went fine. Now we are trying to implement one of
the application scenario, and I am having difficulty in coming up with the
best approach.

Scenario:
We have a Device POJO which have some attributes/fields which are
read/write by users as well as network and some attributes/fields only
network can modify. When users need to configure they will create an
instance of Device POJO and set/configure applicable fields, however
network can update those attributes. We wanted to know the discrepancy by
the values configured by users versus the values updated by network. Hence
we have thought of 3 different approaches

1) Create multiple tables for the same Device like Device_Users and
Device_Network so that we can see the difference.

2) Create different Keyspace as multiple objects like Device can have the
same requirement

3) Create one "Device" table and insert one row for user configuration and
another row for network update. We will create this table with multiple
primary key (device_name, updated_by)

Please let us know which is the best option (with their pros and cons if
possible) among these 3, and also let us know if there are other options.

Thanks and Regards
A.SathishKumar

Re: Designing a table in cassandra

Posted by sat <sa...@gmail.com>.
Hi Carlos Alonso,

Thanks for your quick answer.

Thanks and Regards
A.SathishKumar

On Mon, Nov 7, 2016 at 2:26 AM, Carlos Alonso <in...@mrcalonso.com> wrote:

> Hi,
>
> I think your best bet is, as usual, the simplest one that can work, which,
> to me, in this case is the 3rd one. Creating one single device table that
> contains the different 'versions' of the configuration during time, along
> with a flag to know wether it was updated by user or by network gives you
> all the flexibility you need. The primary key you suggest sounds good to me.
>
> To finally validate the model it would be good to know which are the
> queries you're thinking of running against this model because as you
> probably know, Cassandra models should be query driven.
>
> The suggested primary key will work for queries like "Give me the
> version(s) of this particular device_name in this particular time range"
>
> Hope it helps.
>
> Regards
>
> Carlos Alonso | Software Engineer | @calonso <https://twitter.com/calonso>
>
> On 7 November 2016 at 01:23, sat <sa...@gmail.com> wrote:
>
>> Hi,
>>
>> We are new to Cassandra. For our POC, we tried creating table and
>> inserting them as JSON and all these went fine. Now we are trying to
>> implement one of the application scenario, and I am having difficulty in
>> coming up with the best approach.
>>
>> Scenario:
>> We have a Device POJO which have some attributes/fields which are
>> read/write by users as well as network and some attributes/fields only
>> network can modify. When users need to configure they will create an
>> instance of Device POJO and set/configure applicable fields, however
>> network can update those attributes. We wanted to know the discrepancy by
>> the values configured by users versus the values updated by network. Hence
>> we have thought of 3 different approaches
>>
>> 1) Create multiple tables for the same Device like Device_Users and
>> Device_Network so that we can see the difference.
>>
>> 2) Create different Keyspace as multiple objects like Device can have the
>> same requirement
>>
>> 3) Create one "Device" table and insert one row for user configuration
>> and another row for network update. We will create this table with multiple
>> primary key (device_name, updated_by)
>>
>> Please let us know which is the best option (with their pros and cons if
>> possible) among these 3, and also let us know if there are other options.
>>
>> Thanks and Regards
>> A.SathishKumar
>>
>
>


-- 
A.SathishKumar
044-24735023

Re: Designing a table in cassandra

Posted by Carlos Alonso <in...@mrcalonso.com>.
Hi,

I think your best bet is, as usual, the simplest one that can work, which,
to me, in this case is the 3rd one. Creating one single device table that
contains the different 'versions' of the configuration during time, along
with a flag to know wether it was updated by user or by network gives you
all the flexibility you need. The primary key you suggest sounds good to me.

To finally validate the model it would be good to know which are the
queries you're thinking of running against this model because as you
probably know, Cassandra models should be query driven.

The suggested primary key will work for queries like "Give me the
version(s) of this particular device_name in this particular time range"

Hope it helps.

Regards

Carlos Alonso | Software Engineer | @calonso <https://twitter.com/calonso>

On 7 November 2016 at 01:23, sat <sa...@gmail.com> wrote:

> Hi,
>
> We are new to Cassandra. For our POC, we tried creating table and
> inserting them as JSON and all these went fine. Now we are trying to
> implement one of the application scenario, and I am having difficulty in
> coming up with the best approach.
>
> Scenario:
> We have a Device POJO which have some attributes/fields which are
> read/write by users as well as network and some attributes/fields only
> network can modify. When users need to configure they will create an
> instance of Device POJO and set/configure applicable fields, however
> network can update those attributes. We wanted to know the discrepancy by
> the values configured by users versus the values updated by network. Hence
> we have thought of 3 different approaches
>
> 1) Create multiple tables for the same Device like Device_Users and
> Device_Network so that we can see the difference.
>
> 2) Create different Keyspace as multiple objects like Device can have the
> same requirement
>
> 3) Create one "Device" table and insert one row for user configuration and
> another row for network update. We will create this table with multiple
> primary key (device_name, updated_by)
>
> Please let us know which is the best option (with their pros and cons if
> possible) among these 3, and also let us know if there are other options.
>
> Thanks and Regards
> A.SathishKumar
>

Re: Designing a table in cassandra

Posted by Vladimir Yudovin <vl...@winguzone.com>.
Hi Sathish,



probably I didn't catch exactly your requirements, but why not create single table for all devices, and represent each device as rows, storing both user and network configuration per device. You can use MAP for flexible storage model.



If you have thousandth of devices creating own table for each device can be quite heavy solution. 



Best regards, Vladimir Yudovin, 

Winguzone - Hosted Cloud Cassandra
Launch your cluster in minutes.





---- On Sun, 06 Nov 2016 19:23:20 -0500sat &lt;sathish.alwar@gmail.com&gt; wrote ----




Hi,



We are new to Cassandra. For our POC, we tried creating table and inserting them as JSON and all these went fine. Now we are trying to implement one of the application scenario, and I am having difficulty in coming up with the best approach. 



Scenario:

We have a Device POJO which have some attributes/fields which are read/write by users as well as network and some attributes/fields only network can modify. When users need to configure they will create an instance of Device POJO and set/configure applicable fields, however network can update those attributes. We wanted to know the discrepancy by the values configured by users versus the values updated by network. Hence we have thought of 3 different approaches



1) Create multiple tables for the same Device like Device_Users and Device_Network so that we can see the difference.



2) Create different Keyspace as multiple objects like Device can have the same requirement



3) Create one "Device" table and insert one row for user configuration and another row for network update. We will create this table with multiple primary key (device_name, updated_by)



Please let us know which is the best option (with their pros and cons if possible) among these 3, and also let us know if there are other options.



Thanks and Regards

A.SathishKumar