[ 
https://issues.apache.org/jira/browse/CASSANDRA-1709?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12972716#action_12972716
 ] 

Eric Evans edited comment on CASSANDRA-1709 at 12/22/10 11:20 AM:
------------------------------------------------------------------

Sticking with the theme of being as SQL as reasonable, it makes sense to use 
{{CREATE}} for adding keyspaces and column families, though things get a little 
weird specifying attribute value pairs in place of column schema.  I'm not a 
huge fan of the CLIs {{WITH attr = value AND ...}} but i don't have anything 
better to offer.

{code:sql|title=CREATE}
CREATE (KEYSPACE | COLUMNFAMILY)
    <IDENTIFIER>
WITH
    <ATTR> = <VALUE> AND
    <ATTR> = <VALUE>
    
; Examples
CREATE KEYSPACE Keyspace1 WITH strategy_class = 
"org.apache.cassandra.locator.SimpleStrategy" AND replication_factor = 3;
CREATE COLUMNFAMILY Standard1 WITH comparator_type = "UTF8Type";
{code}

For column metadata, I kind of like the idea of using an adapted {{ALTER}} 
syntax.

{code:sql|title=ALTER}
ALTER <IDENTIFIER> ADD <TERM> WITH <ATTR> = <VALUE> [AND ...]
ALTER <IDENTIFIER> DROP <TERM>
ALTER <IDENTIFIER> ALTER <TERM> SET <ATTR> = <VALUE> [AND ...]

; Examples
ALTER Standard1 ADD "username" WITH index_type = KEYS and validation_class = 
"UTF8Type";
ALTER Standard1 ALTER "city" SET validation_class = "BytesType";
ALTER Standard1 DROP "fullname";
{code}

Updating columnfamily attributes requires venturing a little further outside 
the SQL envelope.  I'm not a fan of the CLI's use of {{UPDATE}} here, it feels 
like an overloading of the term to use it for this.  One idea is to use 
{{ALTER}} for this as well.

{code:sql|title=ALTER-ALT}
ALTER (KEYSPACE|COLUMNFAMILY) <IDENTIFIER> SET <ATTR> = <VALUE> [AND ...]

; Example
ALTER KEYSPACE Keyspace1 SET replication_factor = 5;
ALTER COLUMNFAMILY Standard1 SET comparator_type = "UTF8Type";
{code}

The keyspace and columnfamily removal use-case seems pretty obvious.

{code:sql|title=DROP}
DROP (KEYSPACE | COLUMNFAMILY)

; Examples
DROP KEYSPACE Keyspace1;
DROP COLUMNFAMILY Standard2;
{code}

*Edit: Account for modifying keyspace attributes as well.*
*Edit: Corrected type (s/WHERE/WITH/).*

      was (Author: urandom):
    Sticking with the theme of being as SQL as reasonable, it makes sense to 
use {{CREATE}} for adding keyspaces and column families, though things get a 
little weird specifying attribute value pairs in place of column schema.  I'm 
not a huge fan of the CLIs {{WHERE attr = value AND ...}} but i don't have 
anything better to offer.

{code:sql|title=CREATE}
CREATE (KEYSPACE | COLUMNFAMILY)
    <IDENTIFIER>
WITH
    <ATTR> = <VALUE> AND
    <ATTR> = <VALUE>
    
; Examples
CREATE KEYSPACE Keyspace1 WITH strategy_class = 
"org.apache.cassandra.locator.SimpleStrategy" AND replication_factor = 3;
CREATE COLUMNFAMILY Standard1 WITH comparator_type = "UTF8Type";
{code}

For column metadata, I kind of like the idea of using an adapted {{ALTER}} 
syntax.

{code:sql|title=ALTER}
ALTER <IDENTIFIER> ADD <TERM> WITH <ATTR> = <VALUE> [AND ...]
ALTER <IDENTIFIER> DROP <TERM>
ALTER <IDENTIFIER> ALTER <TERM> SET <ATTR> = <VALUE> [AND ...]

; Examples
ALTER Standard1 ADD "username" WITH index_type = KEYS and validation_class = 
"UTF8Type";
ALTER Standard1 ALTER "city" SET validation_class = "BytesType";
ALTER Standard1 DROP "fullname";
{code}

Updating columnfamily attributes requires venturing a little further outside 
the SQL envelope.  I'm not a fan of the CLI's use of {{UPDATE}} here, it feels 
like an overloading of the term to use it for this.  One idea is to use 
{{ALTER}} for this as well.

{code:sql|title=ALTER-ALT}
ALTER (KEYSPACE|COLUMNFAMILY) <IDENTIFIER> SET <ATTR> = <VALUE> [AND ...]

; Example
ALTER KEYSPACE Keyspace1 SET replication_factor = 5;
ALTER COLUMNFAMILY Standard1 SET comparator_type = "UTF8Type";
{code}

The keyspace and columnfamily removal use-case seems pretty obvious.

{code:sql|title=DROP}
DROP (KEYSPACE | COLUMNFAMILY)

; Examples
DROP KEYSPACE Keyspace1;
DROP COLUMNFAMILY Standard2;
{code}

*Edit: Account for modifying keyspace attributes as well.*
  
> CQL keyspace and column family management
> -----------------------------------------
>
>                 Key: CASSANDRA-1709
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-1709
>             Project: Cassandra
>          Issue Type: Sub-task
>          Components: API
>    Affects Versions: 0.8
>            Reporter: Eric Evans
>            Priority: Minor
>             Fix For: 0.8
>
>   Original Estimate: 0h
>  Remaining Estimate: 0h
>
> CQL specification and implementation for schema management.
> This corresponds to the following RPC methods:
> * system_add_column_family()
> * system_add_keyspace()
> * system_drop_keyspace()
> * system_update_keyspace()
> * system_update_columnfamily()

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to