0% found this document useful (0 votes)
49 views

Cassandra Assignment

The document outlines the creation of tables in a Cassandra database for a transportation system. It defines tables for drivers, vehicles, routes, and station information. Examples are provided for inserting sample data and updating records. Queries are also shown to select data from the different tables, including by attributes like driver name, vehicle ID, route, and station.

Uploaded by

nour.benamor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

Cassandra Assignment

The document outlines the creation of tables in a Cassandra database for a transportation system. It defines tables for drivers, vehicles, routes, and station information. Examples are provided for inserting sample data and updating records. Queries are also shown to select data from the different tables, including by attributes like driver name, vehicle ID, route, and station.

Uploaded by

nour.benamor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Cassandra Assignment – Nour Ben Amor Junior SE 2.

PART 1 :

1)

create keyspace tranz_metro with replication={'class':'SimpleStrategy', 'replication_factor':1};

use tranz_metro;

2.1)

CREATE TABLE driver(

... driver_name text PRIMARY KEY,

... password text,

... mobile int,

... current_position text,

... skill set<text>);

2.2)

INSERT INTO driver (driver_name, password, mobile, current_position, skill) VALUES ('Meriem',
'Mimo123', 21285677, 'Tunis', {'Driving cars'});

3.1)

UPDATE driver SET password = 'new_password' WHERE driver_name = 'Mariem' IF password =


'Mimo123';

3.2)

UPDATE driver SET current_position = 'Wellington' WHERE driver_name = 'Mariem';


3.3)

UPDATE driver SET skill = skill + {'Driving'} WHERE driver_name='Mariem';

4.1)

CREATE TABLE vehicle(

... vehicle_id text PRIMARY KEY,

... status text,

... type text);

4.2)

INSERT INTO vehicle(vehicle_id, status, type) VALUES ('Car_BMW', 'Wellington','Car');

6)

CREATE TABLE IF NOT EXISTS time_table( line_name text PRIMARY KEY, service_no int, station_name
text, latitude double, longitude double, time int, distance double);

7.1)

CREATE TABLE IF NOT EXISTS vehicle_usage (

... vehicle_id text PRIMARY KEY,

... total_distance counter);

8.1)

CREATE TABLE IF NOT EXISTS data_point ( day int PRIMARY KEY, sequence timestam
p, latitude double, longitude double, speed double) ;

9)

CREATE TABLE IF NOT EXISTS station (

... name text PRIMARY KEY,

... latitude double,

... north_neighbour text,

... south_neighbour text);

INSERT INTO station (name, latitude, north_neighbour, south_neighbour) VALUES

... ('Wellington', 40, 'Tunis', 'Sousse');

PART 2 :

1)

CREATE TABLE IF NOT EXISTS driver_working_days( driver_name text PRIMARY KEY,

working_day counter);

SELECT working_day FROM driver_working_days WHERE driver_name = 'Meriam';

2)

SELECT line_name, station_name, time FROM tranz_metro.time_table;


3)

SELECT station_name, service_no, time FROM time_table ORDER BY time DESC;

4)

SELECT station_name, time, line_name, service_no FROM time_table;

5)

UPDATE vehicle SET status = 'in_use' WHERE vehicle_id = 'Car_BMW';

6)

SELECT current_position FROM driver WHERE skill CONTAINS 'Driving cars';

7)

SELECT password FROM driver WHERE driver_name = 'Meriam';

8)

INSERT INTO time_table(line_name,service_no, distance) VALUES (

... 'Car_BMW',2, 50);

SELECT distance FROM time_table WHERE line_name = 'Car_BMW' AND service_no = 2

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy