Cassandra Connector > Introduction to Cassandra Connector > Virtual tables
  

Virtual tables

The Simba Cassandra JDBC driver creates virtual tables if the column family contains collections such as set, list, or map.
Virtual tables depict the normalized view of a Cassandra collection. You can import virtual tables as a Cassandra object and create mappings. The Simba Cassandra JDBC driver creates a virtual table for each collection in the column family. The virtual table for a collection uses the following naming convention by default: <original column family name>_vt_<original collection name>
Each virtual table has a foreign key column that references back to the primary key column in the original column family. The virtual table has an index column or a key column that shows the position of the data within the original list or map. The index column uses the following naming convention by default: <original column name>_index or <original column name>_key. Other columns in the virtual table represent the elements in the array and are named after the array element. If the array is of scalar type, the data column uses the following naming convention by default: <original column name>_value

Example

The following CQL statement defines a Cassandra column family that contains a set:
CREATE TABLE users(
username text PRIMARY KEY,
first_name text,
last_name text,
city text,
last_login timestamp,
emails set<text>
);
When you use the Simba Cassandra JDBC driver to import the column family, the driver creates the users_vt_emails virtual table for the users table.
The following table shows the denormalized view of the users_vt_emails virtual table:
username
emails_value
user1
xyz@gmail.com
user1
abc@hotmail.com
user1
qwe@yahoo.com
user2
zxc@gmail.com
user2
jkl@hotmail.com