788.47K
Category: databasedatabase

Введение в базовые запросы в базах данных

1.

Practice 1
Prerequisites: installed MongoDB

2.

Introduction to Basic Queries in NoSQL
Databases
• Introduction
• Definition of NoSQL databases
• Key characteristics:
Schema-less, flexible, horizontally scalable

3.

Types of NoSQL Databases
• Document-oriented (e.g., MongoDB)
• Key-value stores (e.g., Redis)
• Column-family stores (e.g., Cassandra)
• Graph databases (e.g., Neo4j)

4.

Basic NoSQL Query Concepts
• NoSQL databases use different query languages
• Emphasis on CRUD operations: Create, Read, Update, Delete

5.

Document-Oriented Databases (e.g.,
MongoDB)
• Querying JSON-like documents
• Example query: db.collection.find({ key: value
})

6.

Key-Value Stores (e.g., Redis)
• Simple key-value pairs
• Example query: GET key

7.

Column-Family Stores (e.g., Cassandra)
• Data organized in columns, not rows
• Query using CQL (Cassandra Query Language)
Example query: SELECT * FROM UserProfile WHERE key =
value

8.

Graph Databases (e.g., Neo4j)
• Focus on relationships between data
• Cypher Query Language
Example query:
MATCH (node1)-[:RELATIONSHIP]->(node2)
RETURN node1, node2

9.

Common NoSQL Query
Patterns
• Range queries
• Filtering
• Aggregation

10.

NoSQL Indexing
• Importance of indexing for efficient queries
Example: Creating indexes to speed up read operations

11.

Case study – real-world example of using
NoSQL
• Netflix uses NoSQL databases to store and manage massive
amounts of data, including customer profiles, viewing histories,
and content recommendations. NoSQL databases allow Netflix
to handle large volumes of data and provide fast, reliable
access to data across a distributed network.

12.

Tasks
Task 1: Insert Data
Question: Insert a new document into the "users" collection with the following information: username - ”Timur," email - ”[email protected]," age - 25.
Task 2: Query Data
Question: Retrieve all documents from the "users" collection.
Task 3: Update Data
Question: Update the age of the user with the username ”Timur" to 26 in the "users" collection.
Task 4: Delete Data
Question: Delete the document with the email " [email protected] " from the "users" collection.
Task 5: Indexing
Question: Create an index on the "email" field in the "users" collection.
Task 6: Aggregation
Question: Use aggregation to find the average age of users in the "users" collection.
Task 7: Filtering
Question: Retrieve users aged 30 or older from the "users" collection.
Task 8: Embedded Documents
Question: Insert a document into the "users" collection with an embedded "address" document: { city - ”Astana", state - ASTY" }.
Task 9: Sorting
Question: Retrieve all users from the "users" collection and sort them alphabetically by username.
Task 10: Limit and Skip
Question: Retrieve the first two users from the "users" collection, skipping the first one.
English     Русский Rules