I have a requirement of versioning to be done in Cassandra.

Following is my column family definition

create table file_details(id text primary key, fname text, version int, mimetype text);

I have a secondary index created on fname column.

Whenever I do an insert for the same 'fname', the version should be incremented. And when I retrieve a row with fname it should return me the latest version row.

Is there a better way to do in Cassandra? Please suggest what approach needs to be taken.