The examples above use dynamic cell (internal column) names (i.e. 123, 456, 111, 222). You can achieve that in CQL by using a composite primary keys:
cqlsh:test> DESC TABLE user_by_item ;
CREATE TABLE test.user_by_item (
item_id int,
user_id int,
user_name text,
PRIMARY KEY (item_id, user_id)
);
cqlsh:test> select * from user_by_item WHERE item_id = 111;
item_id | user_id | user_name
---------+---------+-----------
111 | 123 | Jay
111 | 456 | John
(2 rows)
cqlsh:test> select * from user_by_item WHERE item_id = 111 and user_id = 123;
item_id | user_id | user_name
---------+---------+-----------
111 | 123 | Jay
(1 rows)
cqlsh:test> DESCRIBE TABLE item_by_user ;
CREATE TABLE test.item_by_user (
user_id int,
item_id int,
item_name text,
PRIMARY KEY (user_id, item_id)
);
cqlsh:test> SELECT * from item_by_user WHERE user_id = 123;
user_id | item_id | item_name
---------+---------+-----------
123 | 111 | iphone
123 | 222 | ipad
(2 rows)
cqlsh:test> SELECT * from item_by_user WHERE user_id = 123 and item_id = 111;
user_id | item_id | item_name
---------+---------+-----------
123 | 111 | iphone
(1 rows)
The 1st part of your primary key will be your "internal row key", and the 2nd will be used as a "clustering key", i.e will be part of a "internal cell/column" name.
So the tables will be internally/physically stored in the similar way as in your examples, and WITH COMPACT STORAGE
option will give you exactly the same physical layout as in examples
Take a look at http://www.datastax.com/dev/blog/thrift-to-cql3 and http://thelastpickle.com/blog/2013/01/11/primary-keys-in-cql.html for more details.