yats.git

ref: b362bac3fb09192f0bb24608910e2ce6f5aa8959

schema/doc.txt


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
CREATE KEYSPACE yats WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '3'}  AND durable_writes = true;
CREATE TABLE metric (
    id_client text,
    mtime timestamp,
    name text,
    value text,
    PRIMARY KEY ((id_client,name),mtime)
);
CREATE TABLE event (
    id_client text,
    etime timestamp,
    name text,
    PRIMARY KEY (id_client,etime)
);
CREATE TABLE client (
 id text,
 name text,
 created timestamp,
 PRIMARY KEY(id)
);
CREATE TABLE metric_info (
    id_client text,
    name text,
    description text,
    PRIMARY KEY (id_client,name)
);
CREATE TABLE position (
    id_client text,
    ptime timestamp,
    lat double,
    lon double, 
    name text,
    PRIMARY KEY (id_client,ptime)
);
CREATE TABLE sources (
    id_client text,
    name text,
    type text,
    app text,
    description text,
    PRIMARY KEY (id_client,app,type,name)
);
CREATE INDEX ON sources(id_client);

CREATE TABLE location (
    hash text,
    lname text,
    lon double,
    lat double,
    code text,
    cdist double,
    PRIMARY KEY (code,cdist)
);
CREATE TABLE location_label (
    hash text,
    ltype text,
    name text,
    PRIMARY KEY (ltype,hash)
);

// select * from location where lat='' and lon=''
// select * from location where ltype='' and code='' order by cdist
CREATE TABLE location (
    ltype text,
    code text,
    cdist double,
    hash text,
    lat double,
    lname text,
    lon double,
    PRIMARY KEY ((ltype, code), cdist)
)

use case:
1) actual fixed locations ---> index with H3 + precision (or maidenhead + precision)
2) position points on a path with id_client and optionally a timestamp : no space partitioning
select * from location where hash='x'
select * from position where id_user='x' and timestamp>'x'

CREATE TABLE position (
    id_client text,
    ptime timestamp,
    lat double,
    lon double,
    name text,
    PRIMARY KEY (id_client,ptime)
);