LoginSignup
2
1

More than 5 years have passed since last update.

MongoDB Beginning

Last updated at Posted at 2018-06-10

Introduction

MongoDB is a cross-platform, document oriented database that provides, high performance, high availability, and easy scalability. MongoDB works on concept of collection and document.

Comparison

Difference between MongoDB and RDMS.
Or Difference between MongoDB and MySQL.

*Concept

MongoDB RDMS
Database Database
Table Collection
Document Row
Field Column
Embedded Document Table Join
_id Primary Key

*Database Operations

MongoDB RDMS
create database test_database; use test_database
show databases; show dbs
drop database test_database; use test_database; db.dropDatabase()

*Collection Operations

MongoDB RDMS
create table products (…); db.createCollection(“products”)
alter table testcoll add …; Automatically generated
show tables; show collection
drop table products; db.drop("products")

*Document Operations

MongoDB RDMS
insert into products values('a','b'); db.products.insert({ name : ‘a’ , type : “b” })
select * from products; db.products.find()
select name from products where name = 'a' order by name; db.products.find({ name : 'a' }, { name : 1 }).sort({ name : 1 })
select count(*) from products; db.products.count()

Installation

brew update
brew install mongodb
sudo mkdir /data/db
sudo mkdir /var/log/mongodb
sudo chmod go+w /data/db
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1