From f4208cb27d545aabb2b815ba833bc2f06195b6d0 Mon Sep 17 00:00:00 2001 From: Joaquin Casares Date: Fri, 19 Dec 2014 17:51:59 -0600 Subject: [PATCH 1/3] Add support for cql and ddl files --- lib/linguist/languages.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index d69b072a..4b0049b1 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -2615,6 +2615,8 @@ SQL: - .tab - .udf - .viw + - .cql + - .ddl STON: type: data From 0bbccc1bc1f989271dd9f951d87a90b19b0196f0 Mon Sep 17 00:00:00 2001 From: Joaquin Casares Date: Mon, 22 Dec 2014 16:48:22 -0600 Subject: [PATCH 2/3] Properly order extensions --- lib/linguist/languages.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 4b0049b1..4aaa1c21 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -2611,12 +2611,12 @@ SQL: ace_mode: sql extensions: - .sql + - .cql + - .ddl - .prc - .tab - .udf - .viw - - .cql - - .ddl STON: type: data From 5ad9deb19942af766040e69de248c1e9bb58fbb6 Mon Sep 17 00:00:00 2001 From: Joaquin Casares Date: Mon, 5 Jan 2015 13:50:54 -0600 Subject: [PATCH 3/3] Added sample files --- samples/SQL/videodb.cql | 85 +++++++++++++++++++++++++++++++++++++++++ samples/SQL/videodb.ddl | 85 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 170 insertions(+) create mode 100644 samples/SQL/videodb.cql create mode 100644 samples/SQL/videodb.ddl diff --git a/samples/SQL/videodb.cql b/samples/SQL/videodb.cql new file mode 100644 index 00000000..ffa3170e --- /dev/null +++ b/samples/SQL/videodb.cql @@ -0,0 +1,85 @@ +CREATE KEYSPACE videodb WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }; + +use videodb; + +// Basic entity table +// Object mapping ? +CREATE TABLE users ( + username varchar, + firstname varchar, + lastname varchar, + email varchar, + password varchar, + created_date timestamp, + total_credits int, + credit_change_date timeuuid, + PRIMARY KEY (username) +); + +// One-to-many entity table +CREATE TABLE videos ( + videoid uuid, + videoname varchar, + username varchar, + description varchar, + tags list, + upload_date timestamp, + PRIMARY KEY (videoid) +); + +// One-to-many from the user point of view +// Also know as a lookup table +CREATE TABLE username_video_index ( + username varchar, + videoid uuid, + upload_date timestamp, + videoname varchar, + PRIMARY KEY (username, videoid) +); + +// Counter table +CREATE TABLE video_rating ( + videoid uuid, + rating_counter counter, + rating_total counter, + PRIMARY KEY (videoid) +); + +// Creating index tables for tab keywords +CREATE TABLE tag_index ( + tag varchar, + videoid uuid, + timestamp timestamp, + PRIMARY KEY (tag, videoid) +); + +// Comments as a many-to-many +// Looking from the video side to many users +CREATE TABLE comments_by_video ( + videoid uuid, + username varchar, + comment_ts timestamp, + comment varchar, + PRIMARY KEY (videoid,comment_ts,username) +) WITH CLUSTERING ORDER BY (comment_ts DESC, username ASC); + +// looking from the user side to many videos +CREATE TABLE comments_by_user ( + username varchar, + videoid uuid, + comment_ts timestamp, + comment varchar, + PRIMARY KEY (username,comment_ts,videoid) +) WITH CLUSTERING ORDER BY (comment_ts DESC, videoid ASC); + + +// Time series wide row with reverse comparator +CREATE TABLE video_event ( + videoid uuid, + username varchar, + event varchar, + event_timestamp timeuuid, + video_timestamp bigint, + PRIMARY KEY ((videoid,username), event_timestamp,event) +) WITH CLUSTERING ORDER BY (event_timestamp DESC,event ASC); + diff --git a/samples/SQL/videodb.ddl b/samples/SQL/videodb.ddl new file mode 100644 index 00000000..ffa3170e --- /dev/null +++ b/samples/SQL/videodb.ddl @@ -0,0 +1,85 @@ +CREATE KEYSPACE videodb WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }; + +use videodb; + +// Basic entity table +// Object mapping ? +CREATE TABLE users ( + username varchar, + firstname varchar, + lastname varchar, + email varchar, + password varchar, + created_date timestamp, + total_credits int, + credit_change_date timeuuid, + PRIMARY KEY (username) +); + +// One-to-many entity table +CREATE TABLE videos ( + videoid uuid, + videoname varchar, + username varchar, + description varchar, + tags list, + upload_date timestamp, + PRIMARY KEY (videoid) +); + +// One-to-many from the user point of view +// Also know as a lookup table +CREATE TABLE username_video_index ( + username varchar, + videoid uuid, + upload_date timestamp, + videoname varchar, + PRIMARY KEY (username, videoid) +); + +// Counter table +CREATE TABLE video_rating ( + videoid uuid, + rating_counter counter, + rating_total counter, + PRIMARY KEY (videoid) +); + +// Creating index tables for tab keywords +CREATE TABLE tag_index ( + tag varchar, + videoid uuid, + timestamp timestamp, + PRIMARY KEY (tag, videoid) +); + +// Comments as a many-to-many +// Looking from the video side to many users +CREATE TABLE comments_by_video ( + videoid uuid, + username varchar, + comment_ts timestamp, + comment varchar, + PRIMARY KEY (videoid,comment_ts,username) +) WITH CLUSTERING ORDER BY (comment_ts DESC, username ASC); + +// looking from the user side to many videos +CREATE TABLE comments_by_user ( + username varchar, + videoid uuid, + comment_ts timestamp, + comment varchar, + PRIMARY KEY (username,comment_ts,videoid) +) WITH CLUSTERING ORDER BY (comment_ts DESC, videoid ASC); + + +// Time series wide row with reverse comparator +CREATE TABLE video_event ( + videoid uuid, + username varchar, + event varchar, + event_timestamp timeuuid, + video_timestamp bigint, + PRIMARY KEY ((videoid,username), event_timestamp,event) +) WITH CLUSTERING ORDER BY (event_timestamp DESC,event ASC); +