what is the standard practice for creating/deleting tables in Cassandra based application

28 views
Skip to first unread message

Kant Kodali

unread,
Apr 4, 2016, 4:43:35 PM4/4/16
to java-dri...@lists.datastax.com
Hi All,

I am wondering what is the standard practice for creating/deleting tables in Cassandra based application? The create statements in the driver would look really ugly. If I have a separate directory of .CQL files and let people to run through the cqlsh then it would be separate command for everyone since directly executing .CQL file from the Java driver is not an option. I want the application to be able to create tables at a specified host in the property file if they don't exist so that the user don't need to know. Any suggestions will be great!

Thanks,
Kant

Alex Popescu

unread,
Apr 4, 2016, 6:30:11 PM4/4/16
to java-dri...@lists.datastax.com
If my application would need to do this transparently to the end user (I'd probably ask myself twice why this is needed):

1. if the app requires a predefined set of keyspaces/tables, I'd have a setup method that would execute a list of corresponding CREATE statements (I'd make sure to always use the IF NOT EXIST clause)

2. if my app requires to dynamically define keyspaces/tables (which by the way can be a warning sign), I'd look into using SchemaBuilder (https://github.com/datastax/java-driver/blob/3.0/driver-core/src/main/java/com/datastax/driver/core/schemabuilder/SchemaBuilder.java)



--
You received this message because you are subscribed to the Google Groups "DataStax Java Driver for Apache Cassandra User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to java-driver-us...@lists.datastax.com.



--
Bests,

Alex Popescu | @al3xandru
Sen. Product Manager @ DataStax

» DataStax Enterprise - the database for cloud applications. «

Jack Krupansky

unread,
Apr 4, 2016, 7:23:43 PM4/4/16
to java-dri...@lists.datastax.com
It is highly recommended that Cassandra tables be created by some separate, atomic process rather than dynamically by each application client, at least until strong consistency is assured in CASSANDRA-10699.

These open issues need to be fully resolved for that to happen:

IOW, two clients cannot concurrently attempt to create the same table, even if they use IF NOT EXISTS.

Only the administrator of the cluster should create tables, not individual users.


-- Jack Krupansky
Reply all
Reply to author
Forward
0 new messages