I am using the below table in our use case -
create table test_new (
employee_id text,
employee_name text,
value text,
last_modified_date timeuuid,
primary key (employee_id, last_modified_date)
);
create index employee_name_idx on test_new (employee_name);
In my above table employee_id will be unique always starting from 1 till 32767. So our query pattern is like this:
- Give me everything for any of the employee_id?
- Give me everything for what has changed in last 5 minutes?
- Give me everything for any of the employee_name?
I will be inserting below data into my above table -
insert into test_new (employee_id, employee_name, value, last_modified_date)
values ('1', 'e27', 'some_value', now());
insert into test_new (employee_id, employee_name, value, last_modified_date)
values ('2', 'e27', 'some_new_value', now());
insert into test_new (employee_id, employee_name, value, last_modified_date)
values ('3', 'e28', 'some_new_again_value', now());
I am able to execute all my above query patterns but there is still one issue.
My question is about avoiding this particular scenario for the query below. What if, somehow mistakenly tries to execute the query below. If they do, it will then create another row with employee_id as 1 and with other fields? I don't want anyone to insert the same employee_id again if it is already there in the Cassandra database..
insert into test_new (employee_id, employee_name, value, last_modified_date)
values ('1', 'e29', 'some_new_value', now());
Any thoughts? I know is this is a debatable situation because of the debate over using an RDBMS vs Cassandra
And also creating an index on employee_name will cause any problem? In my example, same employee_name can have multiple employee_id but with different values. Keeping in mind that employee_id
won't be larger than 32767
so which means maximum number of rows will be 32767
in the above table..
I am running Cassandra 1.2.9