Workshop External Resources
- Youtube Recording: https://youtu.be/0qhZNfuTiNg
- Slides: https://docs.google.com/presentation/d/1XRQv-lYrat08F249j63__cTHmwEucDOytbo4RUbyrzY/edit?usp=sharing
- Kahoot: https://create.kahoot.it/share/oasis-workshop-7-intro-to-databases/6b8c34e9-85e2-4493-b441-05b0d7fa0274
- Oasis Starting Guide: https://github.com/northeastern-oasis/Ultimate-Oasis-Starting-Guide/tree/master/databases
Congratulations on starting to work with databases! Almost every major application has use for a database at some point, be it to store application user data, posts made in the app, restauraunt ratings, instant messages, and endless more use cases. They truly are essential!
The interactive portion of this workshop will focus on creating and interacting with a MongoDB Atlas cloud database
This time, we'll be needing to work with and run files on our local system. To get set up with that, you'll need to go through the following steps:
- (If you don't have it yet) Install Node.js here. Just choose the LTS version, then go through installer steps.
- Install Git here. Choose your operating system, then go through installer steps.
- Clone this Github repository into a new folder on your machine (in Terminal or Command Prompt, type
git clone REPO_URL
, where REPO_URL is the clone repository found on the top of this page - You're all set! Just have the cloned folder easily accessible and follow along with the workshop to start writing backend code
We will be creating a cluster/some collections in MongoDB Cloud Atlas. The steps to do that are as follows:
-
Create a MongoDB account here (choose "Start Free" and use your school email to sign up)
-
Create a new project--use default settings
- Create a cluster
- Use default settings for creation
- Wait 1-3 mins for process to finish
- Add a new user
- Go to “Database Access” link under “Security” on left-hand side
- Click “Create New User”
- Use Password authentication
- Create a new username+password
- Make sure you copy/remember this password! You will need it soon
- “Database User Privileges” = “Read and write to any database”
- Then add user
- Add your IP Address
- Go to “Network access” link on left-hand side
- Click “Add IP Address”
- Click “Add Current IP Address”
- Because you will be developing on your local machine
- Click “Add Current IP Address”
- Now database is locked down both from a user perspective and an IP perspective
- Create a cluster
-
Add a new collection
- Back in “Clusters” tab, click “Collections” button in your cluster
- Click “Load sample dataset”
-
Create the connection for our database
- Back in the “Clusters” tab, click the “Connect” button in your newly-created cluster
- Driver = Node.js
- Version = 3.6 or later
- Copy the connection string to the clipboard
-
Now we're ready to code!
We will be making a basic Node.js app where we will connect to our database. Our goal is for you to use this starter code to connect your own backends to your Mongo database (or other databases)
In your cloned repository, open index.js in your favorite IDE/text editor and follow along with the rest of the workshop.
We will be concerned with the basic operations outlined in this page:
https://docs.mongodb.com/manual/crud/
Well done finishing the workshop! You now understand the basics of databases and how we can easily create/connect to them in our own applications. Check out the following resources to keep learning:
- Continue trying out Mongo CRUD operations: https://docs.mongodb.com/manual/crud/
- Read through the MongoDB Docs--they have many resources to keep learning https://docs.mongodb.com/manual/
- Check out the Oasis Starting Guide section on frontend development here