Is it possible to store in Cassandra (using CQL) two rows in a one column family with the same column quantity but with a one different column? Something like this:
// column family
'users' : {
// row 1
'john' : {
name: 'John',
lastname: 'Smith',
email: '[email protected]'
}
// row 2
'jack' : {
name: 'Jack',
lastname: 'Sparrow',
age: 33
}
}
My current CQL code:
CREATE KEYSPACE people WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
USE people;
CREATE COLUMNFAMILY users (
username varchar PRIMARY KEY,
name varchar,
lastname varchar,
email varchar
);
INSERT INTO users (username, name, lastname, email) VALUES ('john', 'John', 'Smith', '[email protected]');
ALTER TABLE users DROP email;
ALTER TABLE users ADD age int;
INSERT INTO users (username, name, lastname, age) VALUES ('jack', 'Jack', 'Sparrow', 33);
SELECT * FROM users;
OUTPUT:
username | age | lastname | name
----------+------+----------+------
john | null | Smith | John
jack | 33 | Sparrow | Jack
ALTER TABLE users DROP email;
I will get for Jack's email null value but "physically" this column won't be create for this row, I'm right? – Bakus123