You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cassandra.apache.org by Lokesh Ceeba - Vendor <Lo...@walmart.com> on 2016/03/28 18:09:12 UTC

What is the best way to model this JSON ??

Hello Team,
               How to design/develop the best data model for this ?


var json=[    { "id":"9a55fdf6-eeab-4c83-9c6f-04c7df1b3225",
                "user":"ssatish",
                "event":"business",
                "occurredOn":"09 Mar 2016 17:55:15.292-0600",
                "eventObject":
                {
                                "objectType":"LOAD",
                                "id":"12345",
                                "state":"ARRIVAL",
                                "associatedAttrs":
                                [
                                                {
                                                                "type":"location_id",
                                                                "value":"100"
                                                },
                                                {
                                                                "type":"location_type",
                                                                "value":"STORE"
                                                },
                                                {
                                                                "type":"arrival_ts",
                                                                "value":"2015-12-12T10:10:10"
                                                }
                                ]
} }]


I've taken this approach :

create type event_object_0328
(
Object_Type text,
Object_ID   Int,
Object_State text
)
;


create table Events
(
event_id       timeuuid,
event_type     text,
triggered_by   text,
triggered_ts   timestamp,
Appl_ID        text,
eventObject    frozen<event_object_0328>,
primary key    (event_id)
)
;

Now I need to build the Associated Attributes (Highlighted above in JSON text). The Associated Attributes can be very dynamic and shall come in any (Key,Value) pair combination.




--
Lokesh

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: What is the best way to model this JSON ??

Posted by Ryan Svihla <rs...@foundev.pro>.
Lokesh,

The modeling will change a bit depending on your queries, the rate of update and your tooling (Spring-data-cassandra makes a mess of updating collections for example).  I suggest asking the Cassandra users mailing list for help since this list is for development OF Cassandra.

> On Mar 28, 2016, at 11:09 AM, Lokesh Ceeba - Vendor <Lo...@walmart.com> wrote:
> 
> Hello Team,
>               How to design/develop the best data model for this ?
> 
> 
> var json=[    { "id":"9a55fdf6-eeab-4c83-9c6f-04c7df1b3225",
>                "user":"ssatish",
>                "event":"business",
>                "occurredOn":"09 Mar 2016 17:55:15.292-0600",
>                "eventObject":
>                {
>                                "objectType":"LOAD",
>                                "id":"12345",
>                                "state":"ARRIVAL",
>                                "associatedAttrs":
>                                [
>                                                {
>                                                                "type":"location_id",
>                                                                "value":"100"
>                                                },
>                                                {
>                                                                "type":"location_type",
>                                                                "value":"STORE"
>                                                },
>                                                {
>                                                                "type":"arrival_ts",
>                                                                "value":"2015-12-12T10:10:10"
>                                                }
>                                ]
> } }]
> 
> 
> I've taken this approach :
> 
> create type event_object_0328
> (
> Object_Type text,
> Object_ID   Int,
> Object_State text
> )
> ;
> 
> 
> create table Events
> (
> event_id       timeuuid,
> event_type     text,
> triggered_by   text,
> triggered_ts   timestamp,
> Appl_ID        text,
> eventObject    frozen<event_object_0328>,
> primary key    (event_id)
> )
> ;
> 
> Now I need to build the Associated Attributes (Highlighted above in JSON text). The Associated Attributes can be very dynamic and shall come in any (Key,Value) pair combination.
> 
> 
> 
> 
> --
> Lokesh
> 
> 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: What is the best way to model this JSON ??

Posted by Ryan Svihla <rs...@foundev.pro>.
Lokesh,

The modeling will change a bit depending on your queries, the rate of update and your tooling (Spring-data-cassandra makes a mess of updating collections for example).  I suggest asking the Cassandra users mailing list for help since this list is for development OF Cassandra.

> On Mar 28, 2016, at 11:09 AM, Lokesh Ceeba - Vendor <Lo...@walmart.com> wrote:
> 
> Hello Team,
>               How to design/develop the best data model for this ?
> 
> 
> var json=[    { "id":"9a55fdf6-eeab-4c83-9c6f-04c7df1b3225",
>                "user":"ssatish",
>                "event":"business",
>                "occurredOn":"09 Mar 2016 17:55:15.292-0600",
>                "eventObject":
>                {
>                                "objectType":"LOAD",
>                                "id":"12345",
>                                "state":"ARRIVAL",
>                                "associatedAttrs":
>                                [
>                                                {
>                                                                "type":"location_id",
>                                                                "value":"100"
>                                                },
>                                                {
>                                                                "type":"location_type",
>                                                                "value":"STORE"
>                                                },
>                                                {
>                                                                "type":"arrival_ts",
>                                                                "value":"2015-12-12T10:10:10"
>                                                }
>                                ]
> } }]
> 
> 
> I've taken this approach :
> 
> create type event_object_0328
> (
> Object_Type text,
> Object_ID   Int,
> Object_State text
> )
> ;
> 
> 
> create table Events
> (
> event_id       timeuuid,
> event_type     text,
> triggered_by   text,
> triggered_ts   timestamp,
> Appl_ID        text,
> eventObject    frozen<event_object_0328>,
> primary key    (event_id)
> )
> ;
> 
> Now I need to build the Associated Attributes (Highlighted above in JSON text). The Associated Attributes can be very dynamic and shall come in any (Key,Value) pair combination.
> 
> 
> 
> 
> --
> Lokesh
> 
> 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 ***