Creating databases, tables, and indexes

  1. First, we need to create the database (keyspace) and choose how our nodes will replicate the data​:
CREATE KEYSPACE mydb WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };​
  1. Now, we create a table​:
CREATE TABLE tb_drive ( id uuid PRIMARY KEY, wheel_angle float, acc float, image blob );​

  1. Add some data​ as follows:
INSERT INTO tb_drive (id,wheel_angle,acc) VALUES (now(),0.2,0.5);​
INSERT INTO tb_drive (id,wheel_angle,acc) VALUES (now(),0.1,0.5);​
INSERT INTO tb_drive (id,wheel_angle,acc) VALUES (now(),0.0,0.5);​
  1. Create indexes (at any point in time) to all the columns that you want to query (that's why is fast)​:
CREATE INDEX idxAngle ON tb_drive (wheel_angle);​
CREATE INDEX idxAcc ON tb_drive (acc);​
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset