CSL and Mongo
CSL and Mongo
NoSQL :
Relational Database NoSQL
It is used to handle data coming in low
It is used to handle data coming in high velocity.
velocity.
It gives only read scalability. It gives both read and write scalability.
It manages structured data. It manages all type of data.
Data arrives from one or few locations. Data arrives from many locations.
It supports complex transactions. It supports simple transactions.
It has single point of failure. No single point of failure.
It handles data in less volume. It handles data in high volume.
Transactions written in one location. Transactions written in many locations.
db.collection.insertOne()
It is used to insert a single document
in the collection.
db.collection.insertMany()
It is used to insert multiple
documents in the collection.
db.createCollection()
It is used to create an empty
collection.
• Create Operations Example
• Let’s look at some examples of the Create
operation from CRUD in MongoDB.
It is used to update a single document in the collection that satisfy the given
db.collection.updateOne() criteria.
db.collection.updateMany It is used to update multiple documents in the collection that satisfy the given
() criteria.
db.collection.replaceOne() It is used to replace single document in the collection that satisfy the given criteria.
• Update Operations Example
• Let’s look at some examples of the update
operation from CRUD in MongoDB.
• Example 1: In this example, we are updating
the age of Sumit in the student collection
using db.collection.updateOne() method.
• In this example, we are updating the year of
course in all the documents in the student
collection using db.collection.updateMany()
method.
Apache Cassandra
• Apache Cassandra is a highly scalable,
distributed NoSQL database designed for
handling large amounts of data across many
commodity servers without a single point of
failure.
• It uses a column-oriented data model, which
is optimized for read and write performance at
scale.
A brief overview of how to create, alter, and
drop keyspaces in Cassandra.
• Keyspaces in Cassandra
• A keyspace is a namespace in Cassandra that
defines how data is replicated across the
nodes in the cluster.
• Each keyspace can contain multiple tables.
When you create a keyspace, you specify the
replication strategy and the replication factor,
which determine how data is distributed and
replicated across the cluster.
Creating a Keyspace- Syntax
• use the CREATE KEYSPACE command
• Ease of data replication: It could easily replicate data deployed on any particular
node if it has gone down when available
• Distribution of data: This could be used to store and locate data at various nodes,
which has its great advantage
• Peer-to-peer architecture: It does not follow a typical master-slave concept but
follows peer-to-peer architecture where every node participates equally with
equal responsibilities. As a consequence of this, there is no single point of failure.
• High availability: Since there is no single point of failure, hence it is highly
available around
• High Performance: It has to be very reliable for a big organization that generally
deals with large-scale data
• Schema-less concept: Schema-less concept means that schema could be made
internally as per our requirement
Cassandra Query Language (CQL)
Cassandra Query Language (CQL) is used for interacting with
Cassandra databases. It provides a syntax similar to SQL,
which makes it easier for users familiar with relational
databases to work with Cassandra:
UPDATE table_name
SET column1 = value1, column2 = value2, ...
WHERE primary_key_column = primary_key_value;
Example:
To update the email address for the user with user_id:
UPDATE users
SET email = '[email protected]'
WHERE user_id = some_user_id;
DELETE)
• Delete Data
• To delete data from a table, use the DELETE
statement. This operation removes rows that
match the specified primary key.
• sql
• Copy code
• DELETE FROM keyspace_name.table_name
WHERE primary_key_column =
primary_key_value;
• sql
• Copy code
• DELETE FROM keyspace_name.table_name
WHERE primary_key_column =
primary_key_value;
• o delete the user with user_id 123 from the
users table:
• sql
• Copy code
• DELETE FROM my_keyspace.users WHERE
user_id = 123;