.. _keyspace-ops:

Data modeling in OpsCenter
==========================

In the Data Modeling area of OpsCenter, you can:

* View keyspace properties
* :ref:`Create keyspaces <create-ks>`
* :ref:`Delete keyspaces <delete-ks>`
* :ref:`Create new column families <add-cf>`
* :ref:`View column family properties <manage-column-families>`
* :ref:`Manage performance metrics <manage-column-families>` on column families, such as setting, truncating, or deleting metrics

Keyspace operations
---------------------

Selecting the Data Modeling area in the OpsCenter console lists the keyspaces in the cluster that you are monitoring. You can create a new keyspace or manage keyspaces.

When you create a keyspace, you give it a name, choose a replica placement
strategy, the total number of replicas you want, and how those replicas are
divided across your data centers (if you have a multiple data center cluster).

.. _create-ks:

Creating a keyspace
^^^^^^^^^^^^^^^^^^^^

**To create a new keyspace:**

1. Select **Schema** in the OpsCenter console.

2. Select **Add** in the Schema section of OpsCenter.
    
3. Give the keyspace a name. Keyspace names should not contain spaces or
   special characters or exceed the filename size limit of your operating
   system (for example, 255 bytes on most Linux file systems). Keyspace names are case sensitive.
    
4. Set the replica placement strategy. The replica placement strategy (along
   with the cluster-configured snitch) determines how replicas are placed on
   nodes throughout the cluster. Use one of three built-in replica
   placement strategies:

   * **SimpleStrategy** - Single data center, rack unaware replica placement.
     This is the default strategy.
   * **NetworkTopologyStrategy** - Single or multiple data center, rack aware
     replica placement. This is the recommended strategy.
   * **OldNetworkTopologyStrategy** - Two data centers only, rack aware replica
     placement. This strategy is deprecated.

5. Choose how many total copies that you want of your keyspace data
   (replication factor). The NetworkTopologyStrategy requires you to configure how many replicas you want per data center. The
   data center name you enter should match the data center name used by your
   cluster-configured snitch. Make sure to name the data center(s) correctly
   according to your snitch configuration.
    
6. If you do not want to start defining column families within your new
   keyspace right away, uncheck the **I would like to create a Column Family**
   checkbox.
   
7. Click **Save Keyspace**.

.. _delete-ks:

Managing keyspaces
^^^^^^^^^^^^^^^^^^^

**To manage keyspaces:**

1. Select **Schema** in the OpsCenter console.

2. From the list of keyspaces, select one of the keyspaces. 

   In Keyspace Settings, the replica placement strategy options for the keyspace appear. 

3. From the list of column families (below Settings), select a column family to view its properties and :ref:`to view or change performance tuning metrics <manage-column-families>`.

4. Click **Add** in the Column Family to :ref:`add a column family <add-cf>` to the keyspace.

5. Click **Delete** to delete the keyspace. 

Column family management 
----------------------------

When you create a column family in Cassandra using an application, the CLI, or CQL 2 or earlier, the column family appears in OpsCenter. You can use Schema to manage the column family.  

You can also create one type of column family: the dynamic column family. Dynamic column families are those that do not specify column names or values when the column family is created. An application typically supplies this metadata. CQL 3, the default query language in Cassandra, does not support dynamic column families. Earlier versions of CQL and the CLI support dynamic column families.

This version of OpsCenter does not support defining static column families (per-column meta data), row key data types, or schema information for super column sub-columns described in Cassandra 1.0, or earlier, documentation on http://www.datastax.com.

.. _add-cf:

Creating a dynamic column family
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

**To create a new dynamic column family:**

1. Select **Schema** in the OpsCenter console.

2. From the list of keyspaces, select the keyspace to contain the column family.

3. Give the column family a name. 

   Column family names should not contain spaces or special characters and cannot exceed the filename size limit of your operating system (255 bytes
   on most Linux file systems).
    
   By default, column families are created with standard columns
   (**column_type: Standard**). If you want a column family containing super
   columns choose **column_type: Super**.
    
4. Use **compare_with** to set the default data type for column names (or super
   column names). 

   Setting the default data type also sets the column sort order for the column family. For example, choosing **LongType** would sort the columns within a row in
   numerical order. The sort order cannot be changed after a column family is created, so
   choose wisely.

5. Use **default_validation_class** to set the default data type for column
   values (or super column sub-column values). Always
   set this for dynamic column families. 
    
6. Click **Save Column Family**.

Managing column families
^^^^^^^^^^^^^^^^^^^^^^^^^

.. _manage-column-families:

**To manage column families:**

1. Select **Schema** in the OpsCenter console.

2. From the list of keyspaces, select a keyspace.  

   The #CFs columns shows how many column families each keyspace contains.

3. From the list of the column families, select a column family. Click one of the following buttons:

   * Add

     See :ref:`above <add-cf>`.

   * Delete

     Completely removes the column family from the keyspace. You may select more than one column family in a keyspace to delete.

   * View Metrics

     Presents metrics for a column family. In the Metric Options dialog, select a column family (CF) metric to view. To aggregate measurements across the entire cluster, all nodes in the data center, or in a particular node, select Cluster Wide, All Nodes, or the IP address of a node. At this point, you can add a graph of the measurements to the Performance Metrics area, or choose a different column family to measure.

   * Truncate

     Deletes all data from the column family but does not delete the column family itself. Removal of the data is irreversible.

4. When you select a column family, you see a list of manageable attributes: Properties (fully editable), Metadata (Add or Delete), and Secondary Indexes (Add or Delete).

