-
Notifications
You must be signed in to change notification settings - Fork 2
/
mongoDB_notes.properties
109 lines (73 loc) · 2.33 KB
/
mongoDB_notes.properties
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#Mongo names comes from the word humongous
- no schemas in no sql db
- runs on port 27017
#Collections
- Tables are called collections
#Documents
- records are called documents
#data_type
- Mongo converts Json to BSON(Binary) document behind the scenes.
#BSON_Data_Structure
- no schemas
- no normalization like sql
- data stored together and hence it is efficient
#MongoDB Architecture
1. The application will talk to the drivers eg: Java drivers
2. The driver talks to the MongoDB server
3. The MongoDB server talks to the Storage Engine which stores the data as files
4. Shell client also interacts with the database server
#Storage Engine
- writes data into memory for faster retrieval
#BSON
- Mongo uses Binary Json
- very efficient storage
#Cursor Object
#Projection
- selecting column names
#Data_Types
1. Text
2. Boolean
3. Number (Integer, NumberLong, NumberDecimal)
4. ObjectId
5. ISODate
6. Embedded Documents
7. Array
#Relations
#onetoone
#onetomany
#manytoone
#MongoDB Compass
- GUI tool to interact with the DB
#Replication
- used for disaster recovery
- also used for read scaling for read heavy applications
- uses Replica Set for replication
- replica set is a group of mongod instances that host the same data set
- one node is primary and other nodes are secondaries
- Only primary node can take write operations
- minimum 3 nodes required for replication
#Sharding
- horizontal scaling
- data is split across servers and not replicated
- mongos(router) - forwards the requests to the specific shard
- Shard key is added to every document in which shard does the document belong
- shard key should be distributed
#MongoDB Atlas
- managed MongoDB as a service hosted in AWS, Azure or GCP
#Transactions
- deleting a collections must delete the relevant collections
- eg: deleting users collection must also delete the posts collection
- instead of deleting collections separately
- use it only when u need consistency
- less efficient
#Mongo Drivers
- to connect to Mongod from our application
#Stitch
- serverless
- backend as a service
- focus only on the front end
- we can use stitch to run a function like AWS Lambda or call service like S3 for file upload
#Geospatial Data
- storing location data using GeoJSON data type
- querying geospatial data
- need to add a latitude and longitude of a place in the specified format