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

NoSQL Syntax and Query Mechanisms

Uploaded by

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

NoSQL Syntax and Query Mechanisms

Uploaded by

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

Overview of NoSQL Syntax and Query Mechanisms

NoSQL databases use diverse query mechanisms tailored to their specific data models. Below is an

overview:

1. **Key-Value Stores**

- Data is retrieved based on keys.

- Examples: Redis, Amazon DynamoDB

- Typical Operations:

- `GET` and `SET` for retrieving and storing values.

- Increment/Decrement counters.

- Expiring keys automatically.

- Example in Redis:

SET user:1001 "John Doe"

GET user:1001

2. **Document Stores**

- Queries are based on fields and nested structures within JSON-like documents.

- Examples: MongoDB, CouchDB

- Typical Operations:

- Querying with field conditions.

- Aggregations and projections.

- Example in MongoDB:

db.users.find({ age: { $gt: 25 } })

db.users.updateOne({ name: "John" }, { $set: { age: 30 } })


3. **Column-Family Stores**

- Query by keys and columns using a lightweight query language.

- Examples: Apache Cassandra, HBase

- Typical Operations:

- CRUD operations on rows/columns.

- Range queries.

- Example in Cassandra Query Language (CQL):

SELECT * FROM users WHERE id = '1001';

INSERT INTO users (id, name, age) VALUES ('1001', 'John Doe', 30);

4. **Graph Databases**

- Use graph query languages for traversing and analyzing relationships between nodes.

- Examples: Neo4j, ArangoDB

- Typical Operations:

- Querying relationships (e.g., shortest path, neighbors).

- Pattern matching.

- Example in Cypher (Neo4j):

MATCH (n:Person {name: "John"})-[:FRIEND]->(friend)

RETURN friend.name;

5. **Search-Based NoSQL**

- Full-text search queries.

- Examples: Elasticsearch, Solr

- Typical Operations:

- Text-based search queries.

- Aggregations and analytics.

- Example in Elasticsearch (DSL):


{

"query": {

"match": { "title": "NoSQL basics" }

You might also like