Dynamic Column Families

96 views
Skip to first unread message

Yodit Stanton

unread,
Sep 15, 2013, 5:11:57 PM9/15/13
to clojure-...@googlegroups.com

Is there any way in Cassaforte of creating Dynamic column families?  If we take the example given in the Cassandra documentation of a user subscribing to a number of blog posts.  Can I get a general idea of how I model this table in Cassaforte? 

Pic, below of the data model from the cassandra docs.

Many Thanks,


Yodit

Yodit Stanton

unread,
Sep 15, 2013, 5:23:35 PM9/15/13
to clojure-...@googlegroups.com
Ok reading the documentation some more I can see how to create the dynamic tables.  I am not clear though how a normal insert statement would not add a row to the table instead of a column?

Oleksandr Petrov

unread,
Sep 16, 2013, 3:20:17 AM9/16/13
to clojure-...@googlegroups.com
Hi Yodit,

So called dynamic tables are actually virtual entities. I suppose that the article you're referring to is using Thrift interface, where it may have
been a bit less obvious that dynamic tables, or wide rows don't represent a physical entry, and their structure is only imposed by the cassandra 
data model.


If you create a table with 
CREATE TABLE movies (title varchar, rating int, time timestamp, PRIMARY KEY (title, time));
You can see that `timestamp` is something that will become a "key" of your dynamic table, and "rating" here will become a "value"

Difference between "row" and "column" in your question lays in a partition key: if "title" field, which is a partition key (which may be composite),
if the partition key is new (haven't been in your DB just yet), you'll have a new row inserted. If it is something that was already there, a new column
will be inserted into an existing row. Cassandra identifies it by the second part of the PRIMARY KEY (time in this case).

Via CQL you'll see it as a plain table of "title" (which will be repeated for many records), rating and timestamp though. 

You can dig deeper into Cassandra data model yourself by using Cassandra-cli: http://clojurecassandra.info/articles/troubleshooting.html#toc_4
Which can show you which records are stored in the same row.

In order to make a transposition, you can use a little utility function we wrote, here's an example:

I'll cover it in docs, since just found out it's not yet covered there.

Hope that helps.



--
You received this message because you are subscribed to the Google Groups "Cassaforte, a Clojure client for Apache Cassandra" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure-cassan...@googlegroups.com.
To post to this group, send email to clojure-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/clojure-cassandra/c45eb7a6-72ee-42f7-8153-fd6b4b5f960d%40googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
alex p

Yodit Stanton

unread,
Sep 16, 2013, 5:45:47 PM9/16/13
to clojure-...@googlegroups.com
Thanks Alex!  That was helpful, I have managed to create the tables as I wanted.

Regards,


Yodit
Reply all
Reply to author
Forward
0 new messages