1.8 KiB
Theory https://www.youtube.com/playlist?list=PL4cUxeGkcC9h77dJ-QJlwGlZlTd4ecZOA
-
relational database 1 author can have many books whose information are stored in the other table named Books.
So we have rows,columns, table and joining
Columns is property
and we use sql queries to use them -
non relational database Here instead of rows, columns and tables we use collections and documents Each collection store a specific type of data record like users, authors and books.These records inside collections are called documents So users is collection unlike table in sql. and instead of containing columns and rows it contains document which is more like js object
Here author field has nested object. in sql we would have to use other table for that.
Installation
- In arch use
yay -S mongodb-binthis will install mongodb server and mongodb shell. Make sure to start mongodb service too bysystemctl start mongodbalso install mongodb-tools.mongodb-org-toolsin case of debian andmongodb-tools-binfrom aur in case of arch. it is for import, export and other diagonistic tools - in linux mint/ubuntu https://www.mongodb.com/docs/v7.0/tutorial/install-mongodb-on-ubuntu/#std-label-install-mdb-community-ubuntu
Collections and Documents
Mongodb stores data in BSON which is Binary JSON and returns result in JSON.
Each document has a property _id which is assigned automatically by mongodb and its data type is 'ObjectId'.