Hasankalim Homework4

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Hasan Kalim

Homework 4 Cassandra

Homework4 - Cassandra
Table of Contents
Q1 CQL Commands............................................................................................... 1
Q1 Image(s).......................................................................................................... 1
Q2 CQL Command................................................................................................ 2
Q2 Image(s).......................................................................................................... 2
Q3 CQL Command................................................................................................ 3
Q3 Image(s).......................................................................................................... 3

Hasan Kalim
Homework 4 Cassandra

Q1 CQL Commands
CREATE KEYSPACE homework4 WITH replication =
{'class':'SimpleStrategy','replication_factor':1};
USE homework4;
CREATE TABLE personnel (department text, employee_first_name text,
employee_last_name text, year_hired text, hired_salary text, employeeid text,
reviews map<text, text>, PRIMARY KEY (employeeid));
INSERT INTO personnel (department, employee_first_name, employee_last_name,
year_hired, hired_salary, employeeid, reviews) VALUES ('Accounting', 'Nyota',
'Uhura', '2012', '110000', '123303', {'Year1':'2013', 'Rating1':'5', 'Salary1':'120000',
'Year2':'2012', 'Rating2':'4', 'Salary2':'110000'});
INSERT INTO personnel (department, employee_first_name, employee_last_name,
year_hired, hired_salary, employeeid, reviews) VALUES ('IT', 'Mr.', 'Spock', '2011',
'125000', '101010', {'Year1':'2013', 'Rating1':'5', 'Salary1':'145000', 'Year2':'2012',
'Rating2':'5', 'Salary2':'134000', 'Year3':'2011', 'Rating3':'5', 'Salary3':'125000'});
INSERT INTO personnel (department, employee_first_name, employee_last_name,
year_hired, hired_salary, employeeid, reviews) VALUES ('IT', 'Captain', 'Kirk', '2010',
'105000', '94567', {'Year1':'2013', 'Rating1':'5', 'Salary1':'110000', 'Year2':'2011',
'Rating2':'1', 'Salary2':'110000'});

Q1 Image(s)

Hasan Kalim
Homework 4 Cassandra

Q2 CQL Command
INSERT INTO personnel (department, employee_first_name, employee_last_name,
year_hired, hired_salary, employeeid, reviews) VALUES ('IT', 'Captain', 'Kirk', '2010',
'105000', '94567', {'Year1':'2013', 'Rating1':'5', 'Salary1':'110000', 'Year2':'2011',
'Rating2':'1', 'Salary2':'110000', 'Year3':'2012', 'Rating3':'3', 'Salary3':'110000'});

Q2 Image(s)

Hasan Kalim
Homework 4 Cassandra

Q3 CQL Command
CREATE INDEX personnel_hired_salary on personnel(hired_salary);
SELECT * FROM personnel WHERE hired_salary='125000';

Q3 Image(s)

You might also like