CQL
b>
Keyspace: not selected
b>
CL.ONE
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
CREATE KEYSPACE IF NOT EXISTS plane_club
WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
use plane_club;
DROP TABLE IF EXISTS rentals_by_plane;
CREATE TABLE IF NOT EXISTS rentals_by_plane(
plane uuid,
rental_date date,
club_member smallint,
member_credit_card varchar,
PRIMARY KEY((plane),rental_date)
)
WITH CLUSTERING ORDER BY( rental_date DESC )
AND comment = 'Qn. Find member rentals for a given plane.';
/* POPULATE */
// IC VIOLATION: two members using same credit card
INSERT INTO rentals_by_plane( plane, rental_date, club_member, member_credit_card)
VALUES
( 053b7c6c-ac10-49e3-8583-742686e72a4d, '2020-01-20', 2, '1010202030304040' );
INSERT INTO rentals_by_plane( plane, rental_date, club_member, member_credit_card)
VALUES
( 053b7c6c-ac10-49e3-8583-742686e72a4d, '2020-01-25', 1, '1010202030304040' );
// IC VIOLATION: same member renting two planes same day
INSERT INTO rentals_by_plane( plane, rental_date, club_member, member_credit_card)
VALUES
( 0d96dfa6-07c9-4633-904c-7a079027755c, '2020-01-25', 1, '1010202030304040' );
// null credit card
INSERT INTO rentals_by_plane( plane, rental_date, club_member )
VALUES
( 053b7c6c-ac10-49e3-8583-742686e72a4d, '2020-01-26', 1 );
select * from rentals_by_plane;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
index | plane | rental_date | club_member | member_credit_card |
---|---|---|---|---|
0 | "053b7c6c-ac10-49e3-8583-742686e72a4d" | 2020-01-26T00:00:00.000+0000 | 1 | |
1 | "053b7c6c-ac10-49e3-8583-742686e72a4d" | 2020-01-25T00:00:00.000+0000 | 1 | 1010202030304040 |
2 | "053b7c6c-ac10-49e3-8583-742686e72a4d" | 2020-01-20T00:00:00.000+0000 | 2 | 1010202030304040 |
3 | "0d96dfa6-07c9-4633-904c-7a079027755c" | 2020-01-25T00:00:00.000+0000 | 1 | 1010202030304040 |
1
Displaying 1 - 4 of 4 results for the last statement
Success. 4 elements returned. Duration: 4.052 s.