The document outlines a 2.5-hour NoSQL lab focused on MongoDB, covering topics such as NoSQL database types, installation procedures for Windows and Linux, basic CRUD operations, advanced concepts like aggregation and indexing, and connecting MongoDB with Python using PyMongo. It includes practical tasks for students, such as creating a Library Management System database and implementing various operations. Evaluation criteria for lab submission are also provided, emphasizing installation, CRUD operations, aggregation, Python connectivity, and report submission.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
9 views
Nosql Lab Mongodb
The document outlines a 2.5-hour NoSQL lab focused on MongoDB, covering topics such as NoSQL database types, installation procedures for Windows and Linux, basic CRUD operations, advanced concepts like aggregation and indexing, and connecting MongoDB with Python using PyMongo. It includes practical tasks for students, such as creating a Library Management System database and implementing various operations. Evaluation criteria for lab submission are also provided, emphasizing installation, CRUD operations, aggregation, Python connectivity, and report submission.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3
NoSQL Lab (MongoDB) - 2.
5 Hours
1. Introduction to NoSQL Databases (20 mins)
Why NoSQL? Scalability, high availability, flexibility, and performance. NoSQL Database Types: - Key-Value Store (e.g., Redis, DynamoDB) - Document Store (e.g., MongoDB, CouchDB) - Column-Family Store (e.g., Cassandra, HBase) - Graph Database (e.g., Neo4j, ArangoDB) MongoDB Overview: - A document-oriented NoSQL database. - Uses BSON (Binary JSON) format. - Schema-less (flexible data models). - Supports horizontal scaling & replication.
2. Installing MongoDB (20 mins)
Windows Installation: 1. Download MongoDB from https://www.mongodb.com/try/download/community 2. Install MongoDB Community Edition. 3. Add MongoDB to the system path. 4. Start MongoDB service using `mongod`. 5. Open another terminal and connect using `mongo`.
5. Connecting MongoDB with Python (PyMongo) (30 mins)
Install PyMongo: ```sh pip install pymongo ```
Python Code to Insert and Retrieve Data:
```python import pymongo client = pymongo.MongoClient('mongodb://localhost:27017/') db = client['StudentDB'] collection = db['students'] collection.insert_one({'name': 'Ali', 'age': 21, 'semester': 4}) students = collection.find() for student in students: print(student) ```
6. Assignment for Students
1. Install MongoDB and MongoDB Compass. 2. Create a database for a Library Management System. 3. Insert at least 10 books (title, author, year, category). 4. Implement CRUD operations using MongoDB shell and PyMongo. 5. Apply aggregation to find the average publication year. 6. Use indexing to speed up queries. 7. Export the database using: ```sh mongodump --db LibraryDB --out /path/to/backup ```