MongoDb Tutorial #01 What's MongoDB , MongoDB Databases , Collections And Documents

in #utopian-io6 years ago (edited)

Image Source

Repository

https://github.com/mongodb/mongo

What Will I Learn?

I will learn what's the mongoDb and where to use it , what's the databases and how to create show and drop databases , also what's the collections how to create delete show collections and finally what's the documents how to create  , update , delete and fetch documents .

  • What's mongoDB and where to use it.
  • What's the databases and how to create and delete databases .
  • What's collections and how to create , show and delete collections .
  • What's the documents and how to insert , update , delete and fetch documents .

Requirements

  • You must have knowledge about the databases 
  • You Must have an installed version of mongoDB
  • You should know the basics of SQL  

Difficulty

  • Basic

Description

In this tutorial we will talk about mongoDB , what's the mongoDB , mongoDB databases , collections and documents .

1- What's mongoDB ?

In the past, there was talk about the known data bases between the poles of the programmers from different levels, starting from web developers to the software developers on different platforms, OSX, Linux. The talk was about one type only, RDBMS Relational database management system such as MS SQL Server , IBM DB2, Oracle, MySQL, and Microsoft Access, which rely on saving data within tables. But recently, after the release of a number of JS Frameworks and the rise in the number of JavaScript users, 10GEN started working on a database of a completely different type It is a NoSQL under the name of MongoDB which is a database that has no relationship between the tables and is dependent .

2 - MongoDB Databases : 

a- What is a database ?

Is a set of tables linked to each other to store information so that it can be easily modified and deleted and searched for automatically

b- Creation of databases : 

To create a database you type just ' use nameOfDatabase ' , if there is a database with this name it will switch to it, but if it doesn't exist it will create a new database .

c- Show databases : 

To show databases that you have created you must type the command show dbs to show all databases that you have in your local machine .

d- Drop databases :

To drop database you must firstly use it by the use command , then you type db.dropDatabase() it will give as the true value that the database was successfully removed .

3- Collections : 

a- What's the collections ?

It is similar to the concept of tables in relational database systems, we use it to store data

b- Creation of collections : 

To create a collection we have two ways : 

- The first is to use ' db.createCollection(name) ' where the name is the name of the collection .

- The second way is to use ' db.createCollection(name, options) ' where the options contains 4 parameters 

{ capped : true/false , autoIndexId : true/false , size : number , max : number }

c- Drop Collections : 

To delete a collection you must write the name of the collectio then the use the drop method ' db.nameOfCollection.drop() ' it will be removed .

4- Documents : 

a- what's the documents ?

It's data stored in collections , it depends on '  Binary Encoding Of JSON Objects  ' format.

b- Creation of document : 

To create a new document we must use the collection then insert into it a new document as an object 

db.nameOfCollection.insert({name:'alexendre'})

c-Update document : 

To update document we can use the update method that has two parameters , the first is the document that we want to update and the second is the document that we will set 

db.nameOfCollection.update({name:'alexendre'},{name:'maxim'})

d- Delete document : 

To remove a document we use the remove method , but it must has a query or a condition for example 

db.nameOfCollection({name:'alexendre'})

it will remove the document that has the name equals to alexendre.

e- Fetch data : 

To get the data in a collection we use the find() method it will give as the data as  Binary Encoding Of JSON Objects format

db.nameOfCollection.find()

To get the first object of this collection we use db.nameOfCollection.findOne() , it will give us the first document.

And we have other method to show the documents in other form db.nameOfCollection.find().pretty()

Video Tutorial

Curriculum

  • This is the first tutorial in this series .

Proof of Work Done

https://github.com/alexendre-maxim/mongoDB

Sort:  
Loading...

Hey @alexendre-maxim
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Coin Marketplace

STEEM 0.19
TRX 0.12
JST 0.027
BTC 64927.71
ETH 3517.54
USDT 1.00
SBD 2.36