1
votes

cqlsh create table:

CREATE TABLE emp(
   emp_id int PRIMARY KEY,
   emp_name text,
   emp_city text,
   emp_sal varint,
   emp_phone varint
   );

insert data

INSERT INTO emp (emp_id, emp_name, emp_city,
   emp_phone, emp_sal) VALUES(1,'ram', 'Hyderabad', 9848022338, 50000);

select data

SELECT * FROM emp;

 emp_id |  emp_city | emp_name |  emp_phone | emp_sal
--------+-----------+----------+------------+---------
      1 | Hyderabad |      ram | 9848022338 | 50000
      2 | Hyderabad |    robin | 9848022339 | 40000
      3 |   Chennai |   rahman | 9848022330 | 45000

looks just same as mysql, where is column family, column?

A column family is a container for an ordered collection of rows. Each row, in turn, is an ordered collection of columns. A column is the basic data structure of Cassandra with three values, namely key or column name, value, and a time stamp.

so table emp is a column family?

INSERT INTO emp (emp_id, emp_name, emp_city, emp_phone, emp_sal) VALUES(1,'ram', 'Hyderabad', 9848022338, 50000); is a row which contains columns?

column here is something like emp_id=>1 or emp_name=>ram ??

In Cassandra, although the column families are defined, the columns are not. You can freely add any column to any column family at any time. what does this mean? I can have something like this?

emp_id |  emp_city | emp_name |  emp_phone | emp_sal
--------+-----------+----------+------------+---------
      1 | Hyderabad |      ram | 9848022338 | 50000
      2 | Hyderabad |    robin | 9848022339 | 40000 | asdfasd | asdfasdf
      3 |   Chennai |   rahman | 9848022330 | 45000

A super column is a special column, therefore, it is also a key-value pair. But a super column stores a map of sub-columns. Where is super column, how to create it?

2

2 Answers

0
votes

Column family is an old name, now it's called just table.

About super column, also an old term, you have "Map" data type for example, or user defined data types for more complex structures.

About freely adding columns - in the old days, Cassandra was working with unstructured data paradigm, so you didn't had to define columns before you insert them, for now it isn't possible, since Cassandra team moved to be "structured" only (as many in the DB's industry came to conclusion that unstructured data makes more problems than effort).

Anyway, Cassandra's data representation on storage level is very different from MySQL, and indeed saves only data for the columns that aren't empty. It may look same row when you are running select from cqlsh, but it is stored and queried in very different way.

0
votes

The name column family is an old term for what's now simply called a table, such as "emp" in your example. Each table contains one or many columns, such as "emp_id", "emp_name".

When saying something like being able to freely add columns any time, this would mean that you're always able to omit values for columns (will be null) or add columns using the ALTER TABLE statement.