What is a relational database?
A data item



Nosql vs. relational databases?



Advantages:












Disadvantages:








3) Do not provide relational database for the processing of things.

Directing a summary:

MongoDB is a non-relational database he is a relatively mature NOSQL database technology of a document database

MongoDB data management system is written by C++ language MongoDB support rich add, delete, change and check functions and support

More data types that relational types do not have support for rich add, delete, change and query but they do not support SQL statements

MongoDB has rich programming language interfaces such as Python, PHP, C++, JavaScript, C# and so on

MongoDB is also known as NoSQL that most resembles a relational database






What is data:
To be able to
The computer
Identify processed information
Data structure:
Having one or more relations with one another
The collection of elements and the data in that collection
The composition of the relationship between
Database:
Storing management Data
Factory library
The data set
Data management system:
software
Database system:
Tool set



Relational database
Sqlite:
Advantages:
form
High consistency
Redundancy is low
High integrity
External links
Disadvantages:
Consumption is bigger
Not very good
Satisfy the concurrent
Lock operation
inflexible
Non-relational databases
Advantages:
High concurrency
Extensibility is strong
flexible
Reducing data consistency
Memory cache
Disadvantages:
Poor universality
There is no SQL
Flexible operation
Don’t join
NoSQL:
For low
Huge amounts of concurrent
Distribution of extension
Data structure construction
easy
No classification:
Key value database
Column storage database
Graphic database



MongoDB database:
non-relational
The document
The database
C + +
Add and delete
Rich data types
A number of
programming
interface
No technology in the
More mature






Automatic installation:
/var/lib/mongodb
/etc/mongodb.conf
The/usr/bin or/usr/local/bin
Manual installation:
1. Download
2
Unpack the
Or/usr/local/opt
3
The bin
Adding a command set
The environment variable
PATH = $PATH: /opt/mongodb/bin
export PATH
/etc/rc.local
4. Restart



whereis
The software name
To view
The path



Mongod — dbpath directory
27017



Key/value pair
The document
The document
A collection of
A collection of
The database






Storage Data Comparison












Comparison of concepts:
Table/collection



Create the library:
use databaseName
use
Choose which database to use
It is automatically created when it does not exist
It’s true when you insert data
created
Check the library:






System Database:
admin
local
config



Db:
The global variable
Bind the database object currently in use
Use Selects any database
Db according to the test
Inserting data creates the Test database



Backup:
Mongodump -h host address -d library name -o file name
Recovery:
Mongorestore -h Host address: port number -d library name file path
There is no
Automatic library creation
mongostat
    mongotop
monitoring
Read and write the length
Deleting a Database
Db.dropdatabase ()
Create a collection
Db.createcollection (” Collection name “)
Insert data
Automatically created
Db. Set name. Insert (…)
Query collection:
    show collections
    show tables
Delete collection:
Db. Set name.drop ()



A collection of
rename
Db. Collection name. RenameCollion (” New collection name “)



Documents:
Key:
The domain of the document
Strictly case sensitive
Value:
The data stored in the document
integer
Boolean type
floating-point
   Array
Timestamp
Data
Object           
Null              
String           
Symbol         
binary data  
code             
regex           
ObjectID      
The ObjectID:
No _id field is specified
The domain is automatically added as the primary key


“_id” : ObjectId(“5b764646d4ff0ad8f415f977”)



24 – digit hexadecimal number –> Ensures that all _id values are unique



8-bit document creation time 6-bit machine ID 4-bit process ID 6-bit counter






Documents in the collection:
You don’t have to have the same number of fields
It doesn’t have to be the same domain
Set design principles:
As far as possible,
A kind of content
Try not to
Distributed storage
Level don’t
Too much



Insert document:
Insert ({name:” Tom “, age: 15})
Save ({name:” Tom “, age: 15})
Insert multiple documents:
_id
save
insert
_id
The original document is overwritten