https://github.com/tlklein/mongodb-exercises
This repository contains a series of exercises designed to help users practice basic MongoDB operations such as creating databases, inserting documents, querying collections, and using advanced query operators. The exercises include screenshots and explanations to guide users through each task.
https://github.com/tlklein/mongodb-exercises
cli mongodb mongoosejs terminal
Last synced: about 2 months ago
JSON representation
This repository contains a series of exercises designed to help users practice basic MongoDB operations such as creating databases, inserting documents, querying collections, and using advanced query operators. The exercises include screenshots and explanations to guide users through each task.
- Host: GitHub
- URL: https://github.com/tlklein/mongodb-exercises
- Owner: tlklein
- Created: 2024-05-02T03:06:19.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-12-20T19:20:12.000Z (over 1 year ago)
- Last Synced: 2025-02-14T07:23:46.462Z (over 1 year ago)
- Topics: cli, mongodb, mongoosejs, terminal
- Homepage:
- Size: 529 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# MongoDB Exercises
This repository contains a series of exercises designed to help users practice basic MongoDB operations such as creating databases, inserting documents, querying collections, and using advanced query operators. The exercises include screenshots and explanations to guide users through each task.
## Exercise A: Create and List Databases
1. Create a new database named `employees` using the `use` command.
2. List all databases on your MongoDB instance.
### Screenshot

## Exercise B: Create, Drop, and List Collections
1. Create a database named `temporary`, add a collection named `test` to it, and then drop the database. Report the output of `show dbs` and `show collections` before and after the database drop.
### Screenshot

2. Create multiple collections using department names in the database created in Exercise A.
3. List all collections in the current database.
### Screenshot

## Exercise C: Inserting and Retrieving Documents
1. Insert some employee documents with fields (employee id, name, and salary) into multiple collections created in previous exercises.
2. Use the `find` command to retrieve all the entered data.
### Screenshot

## Exercise D: Querying Documents
1. Add the following employees to any collections.
2. Find 2 documents using the `employee id` field.
3. Find all documents where the `name` field starts with "John".
4. Find all documents where the `name` field contains "John".
5. Find 2 documents using the `name` field.
### Screenshot

## Exercise E: Working with `zips.json`
0. Import the `zips.json` file into MongoDB.
### Screenshot

1. Get all cities with a population of less than 1500.
### Screenshot

2. Find all data for the city "CHESTER" using a query operator.
### Screenshot

3. Use the array query operator to find all entries for locations at `(-84.38570799999999, 45.015207)`.
### Screenshot

4. Use a logical operator to find all entries that match the city "WARREN", or the location at `(-80.76424299999999, 41.231819)`.
### Screenshot

## Exercise F: Using the `$where` Operator
1. Use the `$where` operator to find all employees with a salary over 75,000.
2. Use the `$where` operator to find all employees where the `name` contains "John".
### Screenshot

## Exercise G: Querying Specific Fields
1. Using only one collection from the `employees` database, query all documents in that collection but return only the `name` and `salary` fields.
### Screenshot

## About the Author
This activity was completed as part of the **CIS 4338 Database Administration & Implementation** course at the University of Houston under the guidance of Professor Susan Miertschin.
---
Feel free to contribute, provide feedback, or discuss improvements!