NoSQL - Simple Phone Book

Introduction

NoSQL (MongoDB) is a free, non-relational database.

Note on MongoDB:

Click HERE (link) for some useful Python files.

SQL / MongoDB Terminology and Concepts

SQLMongoDB
databasedatabase
tablecollection
rowdocument
columnfield
indexindex
primary key
any unique column or
column combination
primary key
automatically set
to _id field

Project #1

Build a MongoDB database of people and phone numbers using the mongo shell or Python.

For a full description of the problem and using the mongo shell, go HERE .

For a full description of the problem and using Python, go HERE .

Note: The mongo shell is an interactive JavaScript interface to MongoDB. You can use the mongo shell to query and update data as well as perform administrative operations.

Basic MongoDB Document Format

{                                       <-- document
   first_name: "John",                  <-- string
   last_name: "Doe",                    <-- string
   age: 45,                             <-- number
   memberships: ['mem1","mem2"],        <-- array
   address: {                           <-- object
            street: "44 Main St",
            city: "Los Angles",
            state: "California",
            zip_code:91001
   },
   contacts: [                          <-- array of objects
             {name:"Brad", relationship:"friend"},
             {name:"Carol",relationship:"boss"}
   ]
}

System Setup

1. Install NoSQL (MongoDB)

There are free instances of MongoDB in the cloud. However, for this project, we will install MongoDB on a local machine. In particular, The workstation you are working on. (Linux Mint preferred.)

To install MongoDB

sudo apt install mongodb

To remove MongoDB

sudo apt remove mongodb
sudo apt purge mongodb
sudo apt autoremove

To make MongoDB a service

sudo systemctl status mongodb                  # MongoDB service status

sudo systemctl start mongodb                   # start MongoDB service

sudo systemctl stop mongodb                    # stop MongoDb service

2. Install the Python module (optional)

python3 -m pip install pymongo
or
sudo pip3 install pymongo
PyMongo module documentation can be found HERE.

3. Open the firewall (if necessary)

Things To Consider

Links

How do NoSQL databases work? Simply Explained! (YouTube)
MongoDB In 30 Minutes (YouTube)
Complete Python + MongoDB tutorial: PyMongo in-depth [for beginners] (YouTube)
Write Scripts for the mongo Shell

What is Missing

The biggest piece of the puzzle that is missing is security. Who is allowed access? What can they do? Who is the database administrator?

The next biggest piece is secure network communications.