incubator-cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Techy Teck <comptechge...@gmail.com>
Subject CQL Tables in Cassandra with an Index
Date Fri, 08 Nov 2013 02:53:12 GMT
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 -

    1. Give me everything for any of the employee_id?
    2. Give me everything for what has changed in last 5 minutes?
    3. 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());

So now is there any way to avoid this particular scenario in my above table
for the below query.. Somehow somebody by mistake is trying to execute the
below query then it will 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.. Any thoughts?

    insert into test_new (employee_id, employee_name, value,
last_modified_date) values ('1', 'e29',  'some_new_value', now());

Mime
View raw message