Database Reference
In-Depth Information
1.
First, let's create a keyspace
twitter
and column family
users
:
create keyspace twitter with
strategy_options={replication_factor:1} and
placement_strategy='org.apache.cassandra.locator.SimpleStrategy';
use twitter;
create column family users with
key_validation_class='UTF8Type' and
comparator='UTF8Type' and
default_validation_class='UTF8Type';
Here, while defining a column family, we did not define any columns
with the column family. Columns will be added on the fly against
each row key value.
2.
Store a few columns in the
users
column family for row key value
'imvivek'
:
set users['imvivek']['apress']='apress
author';
set
users['imvivek']['team_marketing']='apress
marketing';
set users['imvivek']['guest']='guest user';
set users['imvivek']['ritaf']='rita fernando';
Here we are adding followers as dynamic columns for user
im-
vivek
.
3.
Let's add
'imvivek'
and
'team_marketing'
as followers for
'ritaf'
:
set users['ritaf']['imvivek']='vivek mishra';
set users['team_marketing']['imvivek']='vivek
mishra';
4.
To view a list of rows in
users
column family (see
Figure 2-4
), use
the following command:
list users;