PascalTurbo
PascalTurbo

Reputation: 2363

Cassandra: How to insert row without name

I need to do some cassandra for study project.

It's really simple:

One Column Family, two colums (let's say 'name' and 'mail')

Now I wanna insert some data to Cassandra like

'name' => 'Horst', 'mail' => '[email protected]'

Don't need nothing more - but cassandra needs an sub name for the column family.

columnFamilyName.ABC ( ... )

Is there a way to insert data without this ABC? I only need the columns - nothing more.

Thank's allot for your help.

Pascal

Upvotes: 0

Views: 367

Answers (2)

DNA
DNA

Reputation: 42586

No, you must always have a row name (key). Pretty much anything will do if you just need a dummy row key:

row1 -> name    mail
        Horst   [email protected]

Or, in principle, you could use row keys instead of column names:

name -> value
        Horst

mail -> value
        [email protected]

or even:

name -> Horst
        []

mail -> [email protected]
        []

Where [] indicates an empty value (Cassandra column values can be left empty).

This is just using Cassandra as a simple hashtable i.e. wasting most of Cassandra's column-store capabilities!

Upvotes: 1

Tyler Hobbs
Tyler Hobbs

Reputation: 6932

Row keys are required and they must be unique -- think of them like primary keys in an RDBMS. If you don't care what they are and you just need them to be unique, you would normally use a UUID. But since you only have two rows, why not just name them 'a' and 'b'?

Upvotes: 2

Related Questions