You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Jack Krupansky <ja...@gmail.com> on 2016/03/28 18:22:37 UTC

Re: *** What is the best way to model this JSON *** ??

As always with Cassandra data modeling, you must start with your intended
query and access patterns as well as the cardinality of your data.

So, what information is your app likely to have when it needs to perform a
query and what information is it going to want to retrieve? What is the
full range of potential queries? Which are the most common and need to be
the fastest?


-- Jack Krupansky

On Mon, Mar 28, 2016 at 12:10 PM, Lokesh Ceeba - Vendor <
Lokesh.Ceeba@walmart.com> wrote:

> Hello Team,
>
>                How to design/develop the best data model for this JSON ?
>
>
>
>
>
> 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 Lokesh Ceeba - Vendor <Lo...@walmart.com>.
Team,
       Here is the listing of data elements..
Search/Sorting criteria:

Search fields

Order by fields

object, id

id

object, id, triggered_ts

triggered_ts

object, id, state

triggered_ts

app_id, triggered_ts

triggered_ts

event_type

object, id, triggered_ts

event_type, triggered_ts

object, id, triggered_ts


Model Layout:

Colume Name

Colume Type



event_type

String

Type of event (BUSINESS, SYSTEM, ERROR, etc.)

uuid

String

Unique identifier

triggered_by

String

User ID

triggered_ts

Date Time (down to micro-second)

Time of event

app_id

String

Process that triggered the event

object

String

Type of object (LOAD, TRIP, LOCATION, CARRIER, etc.)

id

String

Identifier for the object

state

String

Event that happened

associated_object_1

String

what changed

associated_value_1

String

value of it

associated_object_2

String



associated_value_2

String



associated_object_3

String



associated_value_3

String



associated_object_4

String



associated_value_4

String







--
Lokesh

From: Jack Krupansky [mailto:jack.krupansky@gmail.com]
Sent: Monday, March 28, 2016 12:23 PM
To: user@cassandra.apache.org
Subject: Re: *** What is the best way to model this JSON *** ??

As always with Cassandra data modeling, you must start with your intended query and access patterns as well as the cardinality of your data.

So, what information is your app likely to have when it needs to perform a query and what information is it going to want to retrieve? What is the full range of potential queries? Which are the most common and need to be the fastest?


-- Jack Krupansky

On Mon, Mar 28, 2016 at 12:10 PM, Lokesh Ceeba - Vendor <Lo...@walmart.com>> wrote:
Hello Team,
               How to design/develop the best data model for this JSON ?


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 ***


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 ***