Más contenido relacionado Similar a Brief overview of NoSQL & MongoDB for GTUG Tbilisi Event (20) Brief overview of NoSQL & MongoDB for GTUG Tbilisi Event1. NoSQL
Ioseb Dzmanashvili
Lead Architect @ Picktek
Teacher @ Caucasus School of Technology
Monday, April 2, 2012
2. NoSQL is a ill-defined and volatile field
© Martin Fowler
Monday, April 2, 2012
4. NoSQL SQL
MongoDB MySql
CouchDB Oracle
Redis M$SQL
Neo4j PostgreSQL
Cassandra SQLite
Monday, April 2, 2012
5. NoSQL Kinds
• Document Oriented
• Key Value Oriented
• Graph Oriented
• ...
• Something else Oriented
Monday, April 2, 2012
6. Other NoSQL
Characteristics
• No Relational Structures
• No JOIN Queries
• No Schema
• No Complex Transactions
Monday, April 2, 2012
7. MongoDB
open-source, high-performance,
document-oriented database
© MongoDB
Monday, April 2, 2012
8. Why MongoDB?
It is not the strongest of the species
that survives, nor the most intelligent.
It is the one that is most adaptable to
change.
© Charles Darwin
Monday, April 2, 2012
9. Flexible Structure
db.blogposts.insert({
name: "ioseb",
date: "2012-04-01",
title: "NoSQL Sucks",
summary: "Yes it Sucks",
content: "..."
});
Monday, April 2, 2012
10. Flexible Structure
db.blogposts.update({
name: "ioseb"
}, {
name: "ioseb",
date: "2012-04-01",
title: "NoSQL is Cool!",
summary: "Yes it's Cool!",
content: "...",
tags: [
"nosql", "sql"
]
}
);
Monday, April 2, 2012
11. Flexible Structure
var comment = {
name: "john doe",
email: "john@doe.com",
comment: "NoSQL Rulez!!!"
};
db.blogposts.update({
name: "ioseb"
}, {
$push: {
comments: comment
}
}
);
Monday, April 2, 2012
12. Flexible Structure
var post = db.blogposts.find(
{name: "ioseb"}
);
Monday, April 2, 2012
13. Flexible Structure
{
name: "ioseb",
date: "2012-04-01",
title: "NoSQL is Cool!",
summary: "Yes it's Cool!",
content: "...",
tags: [
"nosql", "sql"
],
comments: [
{author: "john", email: "john@doe.com", ...}
]
}
Monday, April 2, 2012
14. Flexible Indexing
// index by name
db.blogposts.ensureIndex(
{name: true}
);
// index by tags array
db.blogposts.ensureIndex(
{tags: true}
);
// index by comments authors
db.blogposts.ensureIndex(
{"comments.author": true}
);
Monday, April 2, 2012
15. Replica Sets
• Asynchronous master/slave replication
• Automatic failover
• Automatic recovery
• Consists of two or more nodes
• Automatic primary node election
Monday, April 2, 2012
16. ...Replica Sets
Member 2 Member 1
Read
Member 3
Primary
Read/Write
Client
Monday, April 2, 2012
17. Easy Configuration
config = {_id: 'GTUG', members: [
{_id: 0, host: 'localhost:27017'},
{_id: 1, host: 'localhost:27018'},
{_id: 2, host: 'localhost:27019'}
]}
rs.initiate(config);
Monday, April 2, 2012
18. ...Replica Sets Arbiter
Member 2
Arbiter
No Data Member 1
Read
Member 3
Primary Read/Write Client
Monday, April 2, 2012
19. Easy Configuration
config = {_id: 'GTUG', members: [
{_id: 0, host: 'localhost:27017'},
{_id: 1, host: 'localhost:27018'},
{_id: 2, host: 'localhost:27019', arbiterOnly: true}
]}
rs.initiate(config);
Monday, April 2, 2012