Sobes.tech
Junior

What NoSQL databases do you know?

sobes.tech AI

Answer from AI

MongoDB, Redis, Cassandra, Couchbase, Neo4j, DynamoDB.

MongoDB: Document-oriented, scalable, flexible schema. Used for storing documents, logs, metadata.

Redis: Key-value, in-memory, high performance. Used for caching, queues, pub/sub.

Cassandra: Wide-column, high availability and scalability. Designed for large volumes of data with high write speed.

Couchbase: Document-oriented, distributed, key-value store. Suitable for web applications, mobile backends.

Neo4j: Graph database, optimized for data relationships. Used for social networks, recommendation systems, relationship analysis.

DynamoDB: Key-value and document-oriented, managed service from AWS, high scalability. For serverless applications, microservices.

# Example query to MongoDB in Python
from pymongo import MongoClient

client = MongoClient('mongodb://localhost:27017/')
db = client['mydatabase']
collection = db['mycollection']

# Insert document
document = {"name": "Alice", "age": 30}
collection.insert_one(document)

# Find document
result = collection.find_one({"name": "Alice"})
# print(result)
# Example working with Redis in Python
import redis

r = redis.Redis(host='localhost', port=6379, db=0)

# Set value
r.set('mykey', 'myvalue')

# Get value
value = r.get('mykey')
# print(value)
# Example working with Cassandra in Python (using driver)
from cassandra.cluster import Cluster

cluster = Cluster(['127.0.0.1'])
session = cluster.connect('mykeyspace')

# Execute query
rows = session.execute("SELECT * FROM mytable;")
# for row in rows:
#     print(row)