no sql and mongodb
TRANSCRIPT
Internet Programming IIYildiz Technical University 2015
MongoDB
Ömer Taşkın
OUTLINE
• NoSQL
• Most Popular NoSQL DBs
• Json & Bson
• Basic Commands
• CRUD Operations
• Indexing
IP II – MongoDB 2
NoSQL
IP II – MongoDB 3
NoSQL
IP II – MongoDB 4
•SQL became a standard;
–American National Standards Institute (ANSI) in 1986
– International Organization for Standardization (ISO) in 1987
NoSQL
IP II – MongoDB 5
• means Not Only SQL
• A Database Management System
• Non-relational!
• No Joins!
• Mostly non-transactional
NoSQL
IP II – MongoDB 6
JSON
IP II – MongoDB 7
{
“name” : “omer”,
“surname : “taskin”
}
JavaScript Object Notation
A data type
Object types places into : { }
Arrays places into : [ ]
BSON
IP II – MongoDB 8
Binary type of JSON
MongoDB
IP II – MongoDB 9
– Scalable
– Document based
– Open Source
– Most popular NoSQL database
MongoDB – Use Cases
IP II – MongoDB 10
– Data analysis
– Caching
– Comment / logging management
MongoDB – Features
IP II – MongoDB 11
– Document Oriented
– Replication
– Sharding
– Indexing
– Load Balancing
– Aggregation
– Server-side JavaScript execution
MongoDB
IP II – MongoDB 12
MongoDB
IP II – MongoDB 13
RDBMS MongoDB
Database Database
Table Collection
Row Document
Join Embedding & Linking
Column Field
MongoDB - Basic Commands
IP II – MongoDB 14
Creates ytu database, if not exists
List all of dbs
List all of collections in selected db
use ytu;
show dbs;
show collections;
MongoDB - CRUD
IP II – MongoDB 15
INSERT command
SELECT commands
INSERT INTO user(name, surname) VALUES (“dummy name”, “dummy surname”);
db.user.find();
db.collectionName.findOne();
SELECT * FROM user
SELECT * FROM user LIMIT 1
db.user.save({“name”:”dummy name”, “surname”: “dummy surname”});
MongoDB - CRUD
IP II – MongoDB 16
SELECT command with LIMIT
db.user.find().limit(10);
db.user.find().limit(10).skip(5);
SELECT * FROM users LIMIT 5,10
SELECT * FROM user;
MongoDB - CRUD
IP II – MongoDB 17
UPDATE command
db.user.update( {“name”:”dummy name”}, {“name”: “omer”});
UPDATE user SET name = ‘omer’ WHERE name = ‘dummy
name’;
MongoDB - CRUD
IP II – MongoDB 18
DELETE command
db.user.remove( {“name”:”omer”});
DELETE FROM user WHERE name = ‘dummy name’;