mongodb
Post on 12-May-2015
240 Views
Preview:
DESCRIPTION
TRANSCRIPT
1
This is a student talk, at the Web Data Management, Search and Retrieval Course, each student is is asked to present his/her synthesis paper. Course Page: http://jarrar-courses.blogspot.com/2013/11/web-data-management.html
Nosql Database
Web Data Management, Search and Retrieval Course (MCOM7348)University of Birzeit, Palestine
January, 2014
Synthesis Paper Talk
Fayez shayeb
Master of Computing, Birzeit UniversityFayez.aauj@hotmail.com
bbbbb
Master of Computing, Birzeit Universitybbbbbbb@yahoo.com
• document-oriented database is a computer program designed for storing, retrieving, and managing document-oriented, or semi structured data, information
Document-oriented database
Comparison
Article- id- authori
d- title- content
Comment- id- articlei
d- messa
ge
Author- id- name- email
Article- _id- title- content- author
- comments[]
Document db Relational
- _id- name- email
Concepts Joins
No joins Joins at "design time", not at "query time“ Due to embedded docs and arrays less joins are needed
Constraints No foreign key constraints Unique indexes
Transactions No commit/rollback Atomic operations
Multiple actions inside the same document Incl. embedded documents
Scalable: good for a lot of data / traffic Horizontal scaling: to more nodes Good for web-apps
Performance No joins and constraints
Dev/user friendly Data is modeled to how the app is going to
use it No conversion between object oriented >
relational No static schema = agile
Benefits
One-to-many
Embedded array / array keys Some queries get harder You can index arrays!
Normalized approach More flexibility A lot less performance
Article- _id- content- tags: {“foo”, “bar”}- comments: {“id1”,
“id2”}
many-to-many
Using array keys No join table
References on both sides
Advantage: simple queriesarticles.Where(p =>
p.CategoryIds.Contains(categoryId))categories.Where(c =>
c.ArticleIds.Contains(articleId)) Disadvantage: duplication, update two docs
Article- _id- content- category_ids : {“id1”,
“id2”}
Category- _id- name- article_ids: {“id7”,
“id8”}
json
• Stands for Javascript Object Notation
• Derived from Javascript scripting language
• Used for representing simple data structures and associative arrays
{ "_id": "BCCD12CBB", "type": "person", "name": "Darth Vader", "age": 63, "headware": ["Helmet", "Sombrero"], "dark_side": true}
{ "_id": "BCCD12CBC", "type": "person", "name": "Luke", "age": 35, "powers": ["Pull", "Jedi Mind Trick"], "dark_side": false}
ReplicationOnly one server is active for writes (the
primary, or master) at a given time – this is to allow strong consistent (atomic) operations. One can optionally send read operations to the secondaries when eventual consistency semantics are acceptable.
ShardingSharding is the partitioning of data among
multiple machines in an order-preserving manner.(horizontal scaling )
Machine 1 Machine 2 Machine 3
Alabama → Arizona Colorado → Florida Arkansas → California
Indiana → Kansas Idaho → Illinois Georgia → Hawaii
Maryland → Michigan Kentucky → Maine Minnesota → Missouri
Montana → Montana Nebraska → New Jersey Ohio → Pennsylvania
New Mexico → North Dakota Rhode Island → South Dakota Tennessee → Utah
Vermont → West Virgina Wisconsin → Wyoming
ShardingThe set of servers/mongod process within
the shard comprise a replica set
Replication & Sharding conclusion
sharding is the tool for scaling a system, and replication is the tool for data safety, high availability, and disaster recovery. The two work in tandem yet are orthogonal concepts in the design.
Document Databases
What is MongoDB?
Creator: 10 gen, former doublick
Name: short for humongous (عمالق)
Language: C++
What is MongoDB?Defination: MongoDB is an open source,
document-oriented database designed with both scalability and developer agility in mind. Instead of storing your data in tables and rows as you would with a relational database, in MongoDB you store JSON-like documents with dynamic schemas(schema-free, schemaless).
Goal: bridge the gap between key-value stores (which are fast and scalable) and relational databases (which have rich functionality).
What is MongoDB?
MongoDB terms ?
Term mapping
Data model: Using BSON (binary JSON), developers can easily map to modern object-oriented languages without a complicated ORM layer.
BSON is a binary format in which zero or more key/value pairs are stored as a single entity.
lightweight, traversable, efficient
MongoDB Data model
Schema designRDBMS: join
Schema design
Schema design
mongodb SQL
db.CreateCollection() Create table
db.coll.save() Insert into
db.coll.find() select
db.coll.update update
db.coll.remove() delete
db.coll.drop() drop
Query MongoDB Vs sql?
Query MongoDB Vs sql?
Query MongoDB Vs sql?
API for MongoDB :
CC++C#ErlangHaskellJavanode.js
PHPPerlPythonRubyScala (Casbah)
27
Thank You
top related