user1050619
user1050619

Reputation: 20896

Cassandra one to one relationship

I have a SQL table with the following structure -

Ticket_info

ticket_num int
region     text
division   text
error_count text
PRIMAR KEY (ticket_num,region)

As the ticket db could grow large we are planning to store in cassandra.

The only issue is that the user can query on any of the fields shown above.

I'm planning to denormalize the data as such -

Ticket_info_region

ticket_num int
region     text
PRIMAR KEY (ticket_num,region)

Ticket_info_division

ticket_num int
division     text
PRIMAR KEY (ticket_num,division)

Ticket_info_error_count

ticket_num int
error_count     text
PRIMAR KEY (ticket_num,error_count)

With the above structure I see 2 issues.

  1. Should I manually merge the results if the user gives multiple conditions?

  2. With multiple tables how can I maintain the data integrity. For ex:- after I insert into the region table, if the division table fails, I will have integrity issues.

Upvotes: 0

Views: 197

Answers (1)

TheGeorgeous
TheGeorgeous

Reputation: 4061

  1. Do not use cassandra to query all the tables together. If such a condition is necessary use cassandra integrated with solr/elasticsearch. There is a solr implementation available from Datastax.

  2. Use Batch updates for atomic updates. This will ensure that all of your updates are performed and in case of failure, nothing is updated.

Upvotes: 2

Related Questions