View
5
Download
0
Category
Preview:
Citation preview
Basics of NoSQL Databases - MongoDB
-11
: ( ) ( )
,
,
databases
SQL databases , table, row,
fields ,records |
structure record databases
- NoSQL Not Only SQL Databases
database |
NoSQL databases
|
NoSQL Databases
,
non-relational database
(Strict) (rigid) |
table record store |
clusters run web data store
| scalability |
bigdata |
databases app web
apps Google Mail, Google Earth, Ebay, LinkedIn,
facebook, Amozon |
users fast response time |
handle
|
feature fast update adopt |
down time performance |
NoSQL Databases
,
1. Key-value Databases
2. Document Databases
3. Column family stores Databases
4. Graph Databases
Key-Value databases python dictionary.
flexible |
Cassandra, Amazon DyanmoDB, ATS (Azure Table Storage, Riak, BerkeleyDB |
,
Document Databases key-value databases |
key-value pair structured semi-
structured document store
|
keys string
values |
MS office document, PDFs, XML,
JSON ,BSON |
JSON (JavaScript Object Notation)
BSON (Binary JSON)
JSON open,
standard modern web
data interchange
XML |
JSON Python dictionaries
|
- MongoDB, Couch DB
DocumentDB |
,
Column Family Store Database column store column family
database
column oriented |
Column family storage
mechanism
rows |
row column |
row key
row
|
- Hbase,
Cassandra, HyperTable |
,
Graph Database store
grafical |
object
nodes
edges nodes
relation |
- Neo4j,
Blazegraph, Titan |
NoSQL Databases Advantages Disadvantages
,
Advantages:
Flexible Data Model
flexible database
type store
|
Evolving Data Model
system down
schema |
Elastic Scalability
database store
|
High Performance
throughput latency
|
Open Source
|
Disadvantages:
Lack of Standardization
NoSQL database
|
Backup of Database
NoSQL databases
backup MongoDB
backup tool
|
Consistency
NoSQL database, consistency
performance scalability
|
duplicacy |
MongoDB
,
MongoDB document-oriented NoSQL database |
dynamic schemas JSON
|
free open source software high scalability high
performance |
MongoDB Terminology
MongoDB Term Description SQL Term
Field name-value pair information | Column
Document Locally related fields Row/record
Collection Related documents Table
Database Collections container. MongoDB server
database |
Database
Primary key Unique field document identify | Primary key
MongoDB install
,
open | https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/#install-mdb-edition
msi version |
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/MongoDB install
,
MSI file open MongoDB install |
path check
mongodb.exe file mongo.exe file |
C:\Program Files\MongoDB\Server\4.0\bin
c:\ data db
| c:\data\db
command window C:\Program
Files\MongoDB\Server\4.0\bin location mongod
run mongod run |
command window open path mongo
run |
MongoDB start
,
Mongo run mongod running state | mongo commands |
mongodb installer 190 MB program files install | C:\Program Files\MongoDB\Server\4.0\bin path system path | windows path |
MongoDB Data Types
,
S.N. Data Type DataType Number
S.N. Data Type DataType Number
1. Double 1 10. Null 11
2. String 2 11. Regular Expression 12
3. Object 3 12. JavaScript 13
4. Array 4 13. Symbol 14
5. Binary Data 5 14. JavaScript with scope 15
6. Undefined 6 15. Integer 16 and 18
7. Object Id 7 16. Timestamp 10
8. Boolean 9 17. Min Key 255
9. Date 10 18. Max Key 127
MongoDB basic commands
,
Database create MongoDB database create |
information database insert database |
Current Database >show dbs database
>show cllections current database collections
Database use >use mydb
CRUD operations operations -
Create
Read
Update
Delete
CRUD operation |
MongoDB basic commands
,
Save operation database MongoDB database create |
information database insert database
|
collection save insert |
db..save({})
show collections collection |
>USE database |
school database 1 collection insert |
MongoDB basic commands
,
Save operation database
documents insert |
document insert mongoDB field
_id value set |
| _id value
insert provide |
Save insert document insert
database collection
mongoDB database |
2 document insert |
MongoDB basic commands
,
Insert operation database collection insert |
db..insert({})
show collections collection |
school database 1 collection insert |
save multiple documents insert
-
>db.teachers.insertMany([{name:Ratan},{name:Krishna,age:45}])
MongoDB basic commands
,
Object Create documents insert
object field object |
stud valid mongoDB |
stud field address value addr |
MongoDB basic commands
,
Object array | Name: Himanshu
Class:11
Section: A
Subjects: English, Hindi, Maths, Physics, Chemistry
Subjects array |
MongoDB basic commands
,
Read Operation: Read operation database collection documents access
| syntaxes |
>db..find() collection documents show |
>db..findOne() record show |
>db..findOne({:}) search criteria
|
record match null return |
MongoDB basic commands
,
Read Operation:
pretty( ) documents indentation JSON print |
MongoDB basic commands
,
Read Operation:
name field _id |
_id |
MongoDB basic Operators
,
Comparison Operator:
databases mongoDB operators
delete, read update operation perform |
Operator Name
Meaning
$eq Equal to
$gt Greater than
$gte Greater than or equal to
$lt Less than
$lte Less than or equal to
$ne Not equal to
MongoDB basic Operators
,
Comparision Operator:
conditional based range |
{field:{$gte:, $lte:}}
MongoDB basic Operators
,
Condition based on List/Array
Operator Name Meaning
$in In
$nin Not In
{ field :{ $in : [ val1,val2, . . . . . ] } }
{ field :{ $nin : [ val1,val2, . . . . . ] } }
Section match show match |
MongoDB basic Operators
,
Logical Query Operators
Operator Name
Meaning
$not Logical NOT
$and Logical AND
$or Logical OR
{ field :{ $not :{}} }
{ field :{ $and :[{}, {},..]} }
{ field :{ $or :[{}, {},..]} }
,
Update Operation: Update operation |
>update/updateOne >updateMany ( $set operator )
>db..update/updateOne({query-exp},{$set:{:, . . . }}
primary key | age 12 Hari Prakash |
matching records changes updateMany( ) |
,
Delete Operation: Delete operation | >deleteOne >deleteMany
>db..deleteOne({}) matching record delete |
>db..deleteMany({}) matching delete |
Hari Prakash record delete
- -
,
www.pythontrends.wordpress.com
http://www.pythontrends.wordpress.com/Recommended