You are on page 1of 3

Name: Sarveswaran MG

RegNo: 20MIA1128

NOSQL Lab Assignment_8_Cassandra_CRUD_operations

Create Business Analytics as keyspace with student_regno as table name. It


should have the
following info
● Name
● Id
● Hobbies of student - set
● Cat1 marks of all subjects in this sem - subject name : mark -map
● No of days absent in each course from day1 to last class of cat1 for all the
subjects – list

cqlsh> CREATE KEYSPACE IF NOT EXISTS BusinessAnalytics WITH replication = {'class':


'SimpleStrategy', 'replication_factor': 1}; cqlsh> USE BusinessAnalytics;
1. Insert min 2 records

cqlsh:businessanalytics> CREATE TABLE IF NOT EXISTS student_1128 (student_id INT


PRIMARY KEY, name TEXT, hobbies SET<TEXT>,cat1_marks MAP<TEXT,
DOUBLE>,days_absent LIST<INT>);

cqlsh:businessanalytics> INSERT INTO student_MIA1126 (student_id, name, hobbies,


cat1_marks, days_absent) VALUES (101, 'sarves', {'cycle', 'Swim'}, {'Maths': 95.5, 'Sci': 78.0}, [0,
0]);

cqlsh:businessanalytics> INSERT INTO student_1128 (student_id, name, hobbies, cat1_marks,


days_absent) VALUES (101, 'sarves', {'cycle', 'Swim'}, {'Maths': 95.5, 'Sci': 78.0}, [0, 0]);

cqlsh:businessanalytics> INSERT INTO student_1128 (student_id, name, hobbies, cat1_marks,


days_absent) VALUES (102, 'sarves mg', {'reading', 'Swiming'}, {'Maths': 99.5, 'Sci': 38.0}, [0, 1]);

cqlsh:businessanalytics> INSERT INTO student_1128 (student_id, name, hobbies, cat1_marks,


days_absent) VALUES (100, 'sarvs', {'reading', 'Swiming'}, {'Maths': 09.5, 'Sci': 37.0}, [1, 1]);
2. Perform update operation on all fields of student table with all attributes

cqlsh:businessanalytics> UPDATE student_1128 SET


name='sarveswaran',hobbies={'Typwriter','trekking'}, cat1_marks= {'Math': 90, 'English':
80},days_absent = [1, 1] WHERE student_id=101;

cqlsh:businessanalytics> UPDATE student_1128 SET name='sarveswaran


MG',hobbies={'Wlking','trekking'}, cat1_marks= {'Math': 30, 'English': 70},days_absent = [0, 0]
WHERE student_id=102;

cqlsh:businessanalytics> UPDATE student_1128 SET


name='sarves',hobbies={'Typwriter','trekking'}, cat1_marks= {'Math': 90, 'English':
80},days_absent = [1, 0] WHERE student_id=100;

3. Do the delete operations for the students whose id is equal to 100

cqlsh:businessanalytics> DELETE FROM student_1128 WHERE student_id = 100;

4. Display the student details who are present in all classes from day 1 to last
day of cat 1 classes for all subjects

You might also like