DataStax
Studio
Schema
default localhost
 
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
88
89
90
CREATE KEYSPACE IF NOT EXISTS architecture
WITH REPLICATION = { 'class': 'SimpleStrategy', 'replication_factor': 1 };
use architecture;
drop materialized view architect_blueprint_by_house_address;
drop materialized view blueprint_house_by_architect;
drop materialized view architect_by_blueprint;
drop table blueprint_by_architect;
CREATE TABLE IF NOT EXISTS blueprint_by_architect(
architect varchar,
blueprint varchar, // blueprint --> architect
is_ncarb_certified boolean static, // architect --> is_ncarb_certified
square_feet smallint, // blueprint property
house_style varchar, // blueprint property
house_address varchar, // if house built yet
PRIMARY KEY( (architect), blueprint ) );
CREATE MATERIALIZED VIEW IF NOT EXISTS architect_blueprint_by_house_address
AS
SELECT architect, blueprint, square_feet, house_style, house_address
FROM blueprint_by_architect
WHERE architect IS NOT NULL AND blueprint IS NOT NULL AND
house_address IS NOT NULL
PRIMARY KEY( (house_address),architect,blueprint );
CREATE MATERIALIZED VIEW IF NOT EXISTS blueprint_house_by_architect
AS
SELECT architect, blueprint, house_address, square_feet, house_style
FROM blueprint_by_architect
WHERE architect IS NOT NULL AND blueprint IS NOT NULL AND
house_address IS NOT NULL
PRIMARY KEY( (architect), blueprint, house_address );
CREATE MATERIALIZED VIEW IF NOT EXISTS architect_by_blueprint
AS
SELECT architect, blueprint, house_address, square_feet, house_style
FROM blueprint_by_architect
WHERE architect IS NOT NULL AND blueprint IS NOT NULL
PRIMARY KEY( (blueprint), architect );
INSERT INTO blueprint_by_architect(architect,blueprint,is_ncarb_certified,square_feet,house_style,house_address)
VALUES
( 'Tony', 'BP_1415', true, 2997, 'Tudor', '16 Gum' );
INSERT INTO blueprint_by_architect(architect,blueprint,is_ncarb_certified,square_feet,house_style)
VALUES
( 'Suzie', 'BP_2890', true, 2200, 'Contemporary' );
INSERT INTO blueprint_by_architect(architect,blueprint,is_ncarb_certified,square_feet,house_style,house_address)
VALUES
( 'Suzie', 'BP_1236', true, 3479, 'Ranch', '61 Ash' );
INSERT INTO blueprint_by_architect(architect,blueprint,is_ncarb_certified,square_feet,house_style,house_address)
VALUES
( 'Rod', 'BP_675', true, 3729, 'Cape Cod', '121 Beech' );
INSERT INTO blueprint_by_architect(architect,blueprint,is_ncarb_certified,square_feet,house_style,house_address)
VALUES
( 'Rod', 'BP_1003', true, 2710, 'Colonial', '72 Juniper' );
/* ------------------------------------------------------- */
select * from blueprint_by_architect;
select * from architect_blueprint_by_house_address;
select * from blueprint_house_by_architect;
select * from architect_by_blueprint;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
indexblueprint architect house_address house_style square_feet
0
BP_1236
Suzie
61 Ash
Ranch
3479
1
BP_1003
Rod
72 Juniper
Colonial
2710
2
BP_1415
Tony
16 Gum
Tudor
2997
3
BP_675
Rod
121 Beech
Cape Cod
3729
4
BP_2890
Suzie
Contemporary
2200
1
Displaying 1 - 5 of 5 results for the last statement
Success. 5 elements returned. Duration: 26.449 s.