Data modeling question

17 views
Skip to first unread message

Greg Saylor

unread,
Aug 15, 2014, 3:41:59 PM8/15/14
to ceq...@googlegroups.com
I have a "problem" that I think Cassandra is well-suited to solve but having some trouble on how to setup the primary key.

Essentially there are 5 columns that I want the primary key to span.   This is specifically (and only) used for de-duplication.  For example:

class IDontKnowWtfIAmDoing
  include Cequel::Record

  column :some_id, :bigint
  column :some_type, :text
  column :something, :text
  column :somewhere_id, :bigint
  column :something_type, :text
  column :wtf_dt, :timestamp
  timestamps
end

But I want a primary key that covers [:some_id, :some_type, :something, :somewhere_id, :something_type]

I have this working fine outside of Cequel, but since "IF NOT EXISTS" is going to be added at some point I'd like to build with as much of Cequel as possible.

All the examples show something like:

  key :id, :uuid

But in this case I want:

   key [ .. bunch of keys ]

Is it possible to model Cequel using this?

Obviously putting a separate primary key would defeat the purpose of using it to deduce across these columns.   I suppose I could create a hash of them, but that seems hack-esque.

- Greg

Greg Saylor

unread,
Aug 15, 2014, 4:12:36 PM8/15/14
to ceq...@googlegroups.com
I think I've figured it out.

Should anyone come across this later, you can define multiple "key"s so its like this:

class IDontKnowWtfIAmDoing
  include Cequel::Record

  key :some_id, :bigint
  key :some_type, :text
  key :something, :text
  key :somewhere_id, :bigint
  key :something_type, :text
  column :wtf_dt, :timestamp
  timestamps
end

Nifty!

- Greg
Reply all
Reply to author
Forward
0 new messages