0
votes

I am trying to link up two tables with the same data like over here: http://outworkers.com/blog/post/a-series-on-cassandra-part-1-getting-rid-of-the-sql-mentality

My second table contains the data I want to query by for example:

foo (
  id text,
  time timestamp,
  a int,
  b int,
  c int,
  d int,
  PRIMARY KEY (time, id)
) WITH CLUSTERING ORDER BY (time DESC, id ASC)

So here I want to query by timestamp or id. Now a,b,c,d are items which should be unique, i.e., the PRIMARY KEY(a, b, c, d). For this I create the first table:

bar (
  id text,
  time timestamp,
  a int,
  b int,
  c int,
  d int,
  PRIMARY KEY (a, b, c, d)
)

The thing is, during the insert, id and time might change but a, b, c, d will remain the same. Now, I was hoping to do something along the lines of that consistency thing mentioned in the blog post. The problem I am facing is that if I try to insert an item with the same (a, b, c, d), bar happily updates the corresponding row but foo creates a new entry. How would I go about deleting the older entry in foo or updating foo like bar???

1

1 Answers

2
votes

According to Cassandra documentation:

UPDATE cannot update the values of a row's primary key fields

And here is example for phantom delete query: https://github.com/outworkers/phantom/wiki/Querying#delete-queries