Databases Reference
In-Depth Information
Compaction min/max thresholds: 4/32
Read repair chance: 1.0
Built indexes: []
Keyspace: system:
...(Information on the system keyspace is not included here as it's
the same as what you have seen earlier in this section)
Next, create a CarDataStore keyspace and a Cars column-family within this keyspace using the
script in Listing 2-1.
LISTING 2-1: Schema script for CarDataStore keyspace
Available for
download on
Wrox.com
/*schema-cardatastore.txt*/
create keyspace CarDataStore
with replication_factor = 1
and placement_strategy = 'org.apache.cassandra.locator.SimpleStrategy';
use CarDataStore;
create column family Cars
with comparator = UTF8Type
and read_repair_chance = 0.1
and keys_cached = 100
and gc_grace = 0
and min_compaction_threshold = 5
and max_compaction_threshold = 31;
schema-cardatastore.txt
You can run the script, illustrated in Listing 2-1, as follows:
PS C:\applications\apache-cassandra-0.7.4> bin/cassandra-cli -host localhost
--file C:\workspace\nosql\examples\schema-cardatastore.txt
You have successfully added a new keyspace! Go back to the script and briefl y review how you
added a keyspace. You added a keyspace called CarDataStore . You also added an artifact called
a ColumnFamily within this keystore. The name of the ColumnFamily was Cars. You will see
ColumnFamily in action in a while, but think of them as tables for now, especially if you can't hold
your curiosity. Within the ColumnFamily tag an attribute called CompareWith was also included.
The value of CompareWith was specifi ed as UTF8Type . The CompareWith attribute value affects
how row-keys are indexed and sorted. The other tags within the keyspace defi nition specify the
replication options. CarDataStore has a replication factor of 1, which means there is only one copy
of data stored in Cassandra.
Next, add some data to the CarDataStore keyspace like so:
[default@unknown] use CarDataStore;
Authenticated to keyspace: CarDataStore
[default@CarDataStore] set Cars['Prius']['make'] = 'toyota';
Search WWH ::




Custom Search