Giter Site home page Giter Site logo

astra-developer-workshop's Introduction

astra-developer-workshop

Use Case

Create keyspace and database

DESCRIBE KEYSPACE;

CREATE KEYSPACE mytestapp WITH REPLICATION = { 'class' : 'org.apache.cassandra.locator.NetworkTopologyStrategy', 'dc-1': '1' } AND DURABLE_WRITES = true;

use mytestapp;

Create table users_by_city

CREATE TABLE IF NOT EXISTS users_by_city ( userid uuid, first_name text, last_name text, email text, city text, address text, PRIMARY KEY ((city), email, userid));

Insert some test data

INSERT INTO users_by_city (userid, first_name, last_name, email, city, address) VALUES (now(), 'vikas', 'kumar', '[email protected]', 'delhi', '110092');

INSERT INTO users_by_city (userid, first_name, last_name, email, city, address) VALUES (now(), 'rahul', 'singh', '[email protected]', 'mumbai', 'andheri east');

Fetch data from table

SELECT * from users_by_city;

city   | email          | userid                               | address      | first_name | last_name
--------+----------------+--------------------------------------+--------------+------------+-----------
  delhi | [email protected] | dfbea2b0-048b-11eb-8d4b-e7907aa277e7 |       110092 |      vikas |     kumar
 mumbai | [email protected] | 029bf580-048c-11eb-8d4b-e7907aa277e7 | andheri east |      rahul |     singh
 

Create table product

CREATE TABLE IF NOT EXISTS products ( productid uuid, product_name text, product_category text, product_description text, PRIMARY KEY ((product_category), productid));

Insert some random data

INSERT INTO products (productid, product_name, product_category, product_description) VALUES (now(), 'monitor', 'computer', 'HP 32 inch FHD monitor');

INSERT INTO products (productid, product_name, product_category, product_description) VALUES (now(), 'Keyboard', 'computer accessories', 'Dell US full keyboard');

INSERT INTO products (productid, product_name, product_category, product_description) VALUES (now(), 'iphone 11', 'mobile', 'iphone 11 black color witrh 128 GB internal storage');

Fetch data from table

product_category     | productid                            | product_description                                 | product_name
----------------------+--------------------------------------+-----------------------------------------------------+--------------
             computer | 55155d30-048f-11eb-8d4b-e7907aa277e7 |                              HP 32 inch FHD monitor |      monitor
               mobile | a8354570-048f-11eb-8d4b-e7907aa277e7 | iphone 11 black color witrh 128 GB internal storage |    iphone 11
 computer accessories | 75eea2a0-048f-11eb-8d4b-e7907aa277e7 |                               Dell US full keyboard |     Keyboard

CRUD operation in tables

UPDATE products SET product_description = 'DELL wireless keyboard and mouse combo' WHERE product_category = 'computer accessories' and productid= 75eea2a0-048f-11eb-8d4b-e7907aa277e7;

SELECT * FROM products WHERE product_category = 'computer accessories' AND productid = 75eea2a0-048f-11eb-8d4b-e7907aa277e7;

product_category     | productid                            | product_description                    | product_name
----------------------+--------------------------------------+----------------------------------------+--------------
 computer accessories | 75eea2a0-048f-11eb-8d4b-e7907aa277e7 | DELL wireless keyboard and mouse combo |     Keyboard

DELETE FROM products WHERE product_category = 'computer accessories' AND productid = 75eea2a0-048f-11eb-8d4b-e7907aa277e7;

SELECT * FROM products;

 product_category | productid                            | product_description                                 | product_name
------------------+--------------------------------------+-----------------------------------------------------+--------------
         computer | 55155d30-048f-11eb-8d4b-e7907aa277e7 |                              HP 32 inch FHD monitor |      monitor
           mobile | a8354570-048f-11eb-8d4b-e7907aa277e7 | iphone 11 black color witrh 128 GB internal storage |    iphone 11

astra-developer-workshop's People

Contributors

vikaskumar144 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.