You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cassandra.apache.org by Ahmed Eljami <ah...@gmail.com> on 2016/01/28 14:28:41 UTC

Modeling nested collection with C* 2.0

​Hi,

I need your help for modeling a nested collection with cassanrda2.0 (UDT no,
no fozen)

My users table contains emails by type, each type of email contains multiple
emails.

Example:
Type: pro. emails: {a@mail.com, b@mail.com ...}

Type: private. emails: {c@mail.com, d@mail.com}
.....

The user table also contains addresses, address type with fields.

Example:

Type: Pro. address {Street= aaa, number = 123, apartment = bbb}

Type: Private. address {Street = bbb, number = 123, apartment = kkk }

I am looking for a solution to store all these columns in one table.

Thank you.

Re: Modeling nested collection with C* 2.0

Posted by Lorand Kasler <lo...@soundcloud.com>.
Maps and Sets have a hard limit of 65536 elements and you always need to
get the full collection even if you are only interested in few elements.
They are well suited to denormalize small datasets but above that it is
better to use Clustering Columns to model these kind of data.

Best,
Lorand

On Thu, Jan 28, 2016 at 4:50 PM, <ae...@orange.com> wrote:

> I need to query all columns by the userid.
>
>
>
> For example: Select * from users where userid  = 123;
>
>
>
> frozen UDT don’t exist in Cassandra 2.0 L
>
>
>
> *De :* Jack Krupansky [mailto:jack.krupansky@gmail.com]
> *Envoyé :* jeudi 28 janvier 2016 16:38
> *À :* user@cassandra.apache.org
> *Objet :* Re: Modeling nested collection with C* 2.0
>
>
>
> Generally, you should use clustering columns to model nested structures,
> unless they really are simply list/map structures.
>
>
>
> But, first, as with all data modeling in Cassandra, start by looking at
> how you intend to query the data. Do you need to query individual
> addresses, email addresses, streets, etc.? If so, separate rows for each
> address is a better way to go. On the flip side, if the full address is
> just a blob that you will interpret in the app, a frozen UDT or JSON blob
> is a reasonable way to go. In any case, tell us about your query needs
> first.
>
>
> -- Jack Krupansky
>
>
>
> On Thu, Jan 28, 2016 at 10:29 AM, Carlos Alonso <in...@mrcalonso.com>
> wrote:
>
> Hi Ahmed,
>
>
>
> I think modelling them as a map where you can 'label' your emails or
> addresses sounds like a good option.
>
>
>
> More info here:
> https://docs.datastax.com/en/cql/3.1/cql/cql_using/use_map_t.html
>
>
>
> Regards
>
>
> Carlos Alonso | Software Engineer | @calonso <https://twitter.com/calonso>
>
>
>
> On 28 January 2016 at 13:36, Ryan Svihla <rs...@foundev.pro> wrote:
>
> Ahmed,
>
>
>
> Just using text and serializing as Json is the easy way and a common
> approach.
>
>
>
> However, this list is for Cassandra commiter discussion, please be so kind
> as to use the regular user list for data modeling questions or for any
> future responses to this email thread.
>
>
>
> Regards,
>
> Ryan Svihla
>
>
> On Jan 28, 2016, at 7:28 AM, Ahmed Eljami <ah...@gmail.com> wrote:
>
> ​Hi,
>
> I need your help for modeling a nested collection with cassanrda2.0 (UDT
> no,
> no fozen)
>
> My users table contains emails by type, each type of email contains
> multiple
> emails.
>
> Example:
> Type: pro. emails: {a@mail.com, b@mail.com ...}
>
> Type: private. emails: {c@mail.com, d@mail.com}
> .....
>
> The user table also contains addresses, address type with fields.
>
> Example:
>
> Type: Pro. address {Street= aaa, number = 123, apartment = bbb}
>
> Type: Private. address {Street = bbb, number = 123, apartment = kkk }
>
> I am looking for a solution to store all these columns in one table.
>
> Thank you.
>
>
>
>
>
> _________________________________________________________________________________________________________________________
>
> Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc
> pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler
> a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration,
> Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci.
>
> This message and its attachments may contain confidential or privileged information that may be protected by law;
> they should not be distributed, used or copied without authorisation.
> If you have received this email in error, please notify the sender and delete this message and its attachments.
> As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified.
> Thank you.
>
>

RE: Modeling nested collection with C* 2.0

Posted by ae...@orange.com.
I need to query all columns by the userid.

For example: Select * from users where userid  = 123;

frozen UDT don’t exist in Cassandra 2.0 ☹

De : Jack Krupansky [mailto:jack.krupansky@gmail.com]
Envoyé : jeudi 28 janvier 2016 16:38
À : user@cassandra.apache.org
Objet : Re: Modeling nested collection with C* 2.0

Generally, you should use clustering columns to model nested structures, unless they really are simply list/map structures.

But, first, as with all data modeling in Cassandra, start by looking at how you intend to query the data. Do you need to query individual addresses, email addresses, streets, etc.? If so, separate rows for each address is a better way to go. On the flip side, if the full address is just a blob that you will interpret in the app, a frozen UDT or JSON blob is a reasonable way to go. In any case, tell us about your query needs first.

-- Jack Krupansky

On Thu, Jan 28, 2016 at 10:29 AM, Carlos Alonso <in...@mrcalonso.com>> wrote:
Hi Ahmed,

I think modelling them as a map where you can 'label' your emails or addresses sounds like a good option.

More info here: https://docs.datastax.com/en/cql/3.1/cql/cql_using/use_map_t.html

Regards

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

On 28 January 2016 at 13:36, Ryan Svihla <rs...@foundev.pro>> wrote:
Ahmed,

Just using text and serializing as Json is the easy way and a common approach.

However, this list is for Cassandra commiter discussion, please be so kind as to use the regular user list for data modeling questions or for any future responses to this email thread.


Regards,
Ryan Svihla

On Jan 28, 2016, at 7:28 AM, Ahmed Eljami <ah...@gmail.com>> wrote:
​Hi,

I need your help for modeling a nested collection with cassanrda2.0 (UDT no,
no fozen)

My users table contains emails by type, each type of email contains multiple
emails.

Example:
Type: pro. emails: {a@mail.com<ma...@mail.com>, b@mail.com<ma...@mail.com> ...}

Type: private. emails: {c@mail.com<ma...@mail.com>, d@mail.com<ma...@mail.com>}
.....

The user table also contains addresses, address type with fields.

Example:

Type: Pro. address {Street= aaa, number = 123, apartment = bbb}

Type: Private. address {Street = bbb, number = 123, apartment = kkk }

I am looking for a solution to store all these columns in one table.

Thank you.



_________________________________________________________________________________________________________________________

Ce message et ses pieces jointes peuvent contenir des informations confidentielles ou privilegiees et ne doivent donc
pas etre diffuses, exploites ou copies sans autorisation. Si vous avez recu ce message par erreur, veuillez le signaler
a l'expediteur et le detruire ainsi que les pieces jointes. Les messages electroniques etant susceptibles d'alteration,
Orange decline toute responsabilite si ce message a ete altere, deforme ou falsifie. Merci.

This message and its attachments may contain confidential or privileged information that may be protected by law;
they should not be distributed, used or copied without authorisation.
If you have received this email in error, please notify the sender and delete this message and its attachments.
As emails may be altered, Orange is not liable for messages that have been modified, changed or falsified.
Thank you.


Re: Modeling nested collection with C* 2.0

Posted by Jack Krupansky <ja...@gmail.com>.
Generally, you should use clustering columns to model nested structures,
unless they really are simply list/map structures.

But, first, as with all data modeling in Cassandra, start by looking at how
you intend to query the data. Do you need to query individual addresses,
email addresses, streets, etc.? If so, separate rows for each address is a
better way to go. On the flip side, if the full address is just a blob that
you will interpret in the app, a frozen UDT or JSON blob is a reasonable
way to go. In any case, tell us about your query needs first.

-- Jack Krupansky

On Thu, Jan 28, 2016 at 10:29 AM, Carlos Alonso <in...@mrcalonso.com> wrote:

> Hi Ahmed,
>
> I think modelling them as a map where you can 'label' your emails or
> addresses sounds like a good option.
>
> More info here:
> https://docs.datastax.com/en/cql/3.1/cql/cql_using/use_map_t.html
>
> Regards
>
> Carlos Alonso | Software Engineer | @calonso <https://twitter.com/calonso>
>
> On 28 January 2016 at 13:36, Ryan Svihla <rs...@foundev.pro> wrote:
>
>> Ahmed,
>>
>> Just using text and serializing as Json is the easy way and a common
>> approach.
>>
>> However, this list is for Cassandra commiter discussion, please be so
>> kind as to use the regular user list for data modeling questions or for any
>> future responses to this email thread.
>>
>>
>> Regards,
>> Ryan Svihla
>>
>> On Jan 28, 2016, at 7:28 AM, Ahmed Eljami <ah...@gmail.com> wrote:
>>
>> ​Hi,
>>
>> I need your help for modeling a nested collection with cassanrda2.0 (UDT
>> no,
>> no fozen)
>>
>> My users table contains emails by type, each type of email contains
>> multiple
>> emails.
>>
>> Example:
>> Type: pro. emails: {a@mail.com, b@mail.com ...}
>>
>> Type: private. emails: {c@mail.com, d@mail.com}
>> .....
>>
>> The user table also contains addresses, address type with fields.
>>
>> Example:
>>
>> Type: Pro. address {Street= aaa, number = 123, apartment = bbb}
>>
>> Type: Private. address {Street = bbb, number = 123, apartment = kkk }
>>
>> I am looking for a solution to store all these columns in one table.
>>
>> Thank you.
>>
>>
>

Re: Modeling nested collection with C* 2.0

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

I think modelling them as a map where you can 'label' your emails or
addresses sounds like a good option.

More info here:
https://docs.datastax.com/en/cql/3.1/cql/cql_using/use_map_t.html

Regards

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

On 28 January 2016 at 13:36, Ryan Svihla <rs...@foundev.pro> wrote:

> Ahmed,
>
> Just using text and serializing as Json is the easy way and a common
> approach.
>
> However, this list is for Cassandra commiter discussion, please be so kind
> as to use the regular user list for data modeling questions or for any
> future responses to this email thread.
>
>
> Regards,
> Ryan Svihla
>
> On Jan 28, 2016, at 7:28 AM, Ahmed Eljami <ah...@gmail.com> wrote:
>
> ​Hi,
>
> I need your help for modeling a nested collection with cassanrda2.0 (UDT
> no,
> no fozen)
>
> My users table contains emails by type, each type of email contains
> multiple
> emails.
>
> Example:
> Type: pro. emails: {a@mail.com, b@mail.com ...}
>
> Type: private. emails: {c@mail.com, d@mail.com}
> .....
>
> The user table also contains addresses, address type with fields.
>
> Example:
>
> Type: Pro. address {Street= aaa, number = 123, apartment = bbb}
>
> Type: Private. address {Street = bbb, number = 123, apartment = kkk }
>
> I am looking for a solution to store all these columns in one table.
>
> Thank you.
>
>

Re: Modeling nested collection with C* 2.0

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

Just using text and serializing as Json is the easy way and a common approach.

However, this list is for Cassandra commiter discussion, please be so kind as to use the regular user list for data modeling questions or for any future responses to this email thread.


Regards,
Ryan Svihla

> On Jan 28, 2016, at 7:28 AM, Ahmed Eljami <ah...@gmail.com> wrote:
> 
> ​Hi,
> 
> I need your help for modeling a nested collection with cassanrda2.0 (UDT no,
> no fozen)
> 
> My users table contains emails by type, each type of email contains multiple
> emails.
> 
> Example:
> Type: pro. emails: {a@mail.com, b@mail.com ...}
> 
> Type: private. emails: {c@mail.com, d@mail.com}
> .....
> 
> The user table also contains addresses, address type with fields.
> 
> Example:
> 
> Type: Pro. address {Street= aaa, number = 123, apartment = bbb}
> 
> Type: Private. address {Street = bbb, number = 123, apartment = kkk }
> 
> I am looking for a solution to store all these columns in one table.
> 
> Thank you.

Re: Modeling nested collection with C* 2.0

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

Just using text and serializing as Json is the easy way and a common approach.

However, this list is for Cassandra commiter discussion, please be so kind as to use the regular user list for data modeling questions or for any future responses to this email thread.


Regards,
Ryan Svihla

> On Jan 28, 2016, at 7:28 AM, Ahmed Eljami <ah...@gmail.com> wrote:
> 
> ​Hi,
> 
> I need your help for modeling a nested collection with cassanrda2.0 (UDT no,
> no fozen)
> 
> My users table contains emails by type, each type of email contains multiple
> emails.
> 
> Example:
> Type: pro. emails: {a@mail.com, b@mail.com ...}
> 
> Type: private. emails: {c@mail.com, d@mail.com}
> .....
> 
> The user table also contains addresses, address type with fields.
> 
> Example:
> 
> Type: Pro. address {Street= aaa, number = 123, apartment = bbb}
> 
> Type: Private. address {Street = bbb, number = 123, apartment = kkk }
> 
> I am looking for a solution to store all these columns in one table.
> 
> Thank you.