MongoDB NOSQL Kashif Murtaza Muhammad Ahmad AI Sciences Instructor @AISciencesLearn Overview Installation Components ▪ Atlas ▪ Mongo ▪ MongoD ▪ Compass Analogies Analogies MySQL MongoDB Database Database Tables Collection Rows Documents Columns Fields Database Analogies MySQL MongoDB Database Database Tables Collection Rows Documents Columns Fields Collections Analogies MySQL MongoDB Database Database Tables Collection Rows Documents Columns Fields CREATE Operation Update Operation Read Operation Delete Operation Quiz Quiz ▪ For the quiz we are performing some create document operations ▪ You have to create a database or used an existing one. ▪ Create a collection CreateQuiz in it. ▪ Insert data of “Student Marks” based on the following data: ▪ ▪ ▪ ▪ ▪ Student name, Maths, English, Science, History Student name, English, Science, French Student name, Science, History, French Student name Student name, Maths, English, Science, History, French Quiz Quiz ▪ For the quiz we are performing some read document operations ▪ For this we’ll be using data from the previous Quiz present in CreateQuiz. ▪ Print all the documents present in the collection ▪ In formatted manner, print all the documents present in the collection ▪ Print the marks of Flavin ▪ Print all those documents in which students got 9 marks in French ▪ Print all those documents in which students Science and History marks are 8 and 9.5 Quiz Quiz ▪ For the quiz we are performing some update document operations ▪ For this we’ll be using data from the previous Quiz present in CreateQuiz. ▪ Add the marks for English, Science and French for student with ID 60f34d372e20cfb86f4d66ff Quiz Quiz ▪ For the quiz we are performing some delete document operations ▪ For this we’ll be using data from the previous Quiz present in CreateQuiz. ▪ Delete all the documents who have got 9 marks in French ▪ Delete all the documents where name is John ▪ Delete all the remaining documents Query and Projection Operators Comparison $eq Operator $gt Operator $lt Operator $in Operator $ne Operator $nin Operator Logical $and Operator $or Operator $not Operator Element $exists Operator $type Operator Evaluation $expr Operator $mod Operator $text Operator Array $all Operator $elemMatch Operator $size Operator Projection $ operator $slice operator Quiz Quiz ▪ For the quiz we are performing some equal checks ▪ Use the data present the file ▪ Show all those documents that have qty 15 ▪ Show all those documents that have code 000 ▪ Show all those documents that contains C in their tags Quiz Quiz ▪ For the quiz we are performing some greater then checks ▪ Use the data present the file ▪ Show all those documents that have qty greater than 15 ▪ Show all those documents that have size greater than 12 Quiz Quiz ▪ For the quiz we are performing some greater than or equal to checks ▪ Use the data present the file ▪ Show all those documents that have qty at least 15 ▪ Show all those documents that have size greater than or equal to 12 ▪ Show all those documents that have the size 2 in it ▪ Show all those documents that have the sizes greater than or equal to 10 Quiz Quiz ▪ For the quiz we are performing some in checks ▪ Use the data present the file ▪ Show all those documents that have qty either 15, 25, 35 ▪ Show all those documents that have sizes either 2 or 22 in it ▪ Show the items with the code 123 and 000 ▪ Show the items that have tag [A, B] or D in it Quiz Quiz ▪ For the quiz we are performing some less than checks ▪ Use the data present the file ▪ Show all those documents that have qty less than 15 ▪ Show all those documents that have size less than 12 Quiz Quiz ▪ For the quiz we are performing some less than or equal to checks ▪ Use the data present the file ▪ Show all those documents that have qty at most 15 ▪ Show all those documents that have size less than or equal to 12 ▪ Show all those documents that have the size 2 in it ▪ Show all those documents that have the sizes less than or equal to 10 Quiz Quiz ▪ For the quiz we are performing some not equal to checks ▪ Use the data present the file ▪ Show all those documents that have qty not equal to 20 ▪ Show all those documents where size is not 10 ▪ Show all those documents that do not contain 5 in there sizes Quiz Quiz ▪ For the quiz we are performing some not in checks ▪ Use the data present the file ▪ Show all those documents that have qty none of these 15, 25, 35 ▪ Show all those documents that have none of these sizes 2 or 22 in it ▪ Show the documents that have none of these code 123 and 000 ▪ Show the documents that have none of these tag [A, B] or D in it ▪ Show the documents whose name is not xy or ab Quiz Quiz ▪ For the quiz we are performing and operations ▪ Use the data present the file ▪ Show all those documents where qty is not 15 and size is 15 ▪ Show all those documents where tags contains D and name is ab ▪ Show all those documents where code is not 123 and qty is greater than 15 and tags contains A Quiz Quiz ▪ For the quiz we are performing or operations ▪ Use the data present the file ▪ Show all those documents where name is ab or qty is not 15 or size is 15 ▪ Show all those documents where tags contains D or C or name is ab ▪ Show all those documents where code is not 123 or qty is greater than 15 or tags contains A or D ▪ Show all those documents where qty is 15 and name is ab or qty is 20 and name is cd Quiz Quiz ▪ For the quiz we are performing not operations ▪ Use the data present the file ▪ Show all those documents where name is not ab or qty is not 15 or size is 15 ▪ Show all those documents where tags do not contains D or C or name is not ab ▪ Show all those documents where code is not 123 or qty is greater than 15 or tags do not contains A or D ▪ Show all those documents where Quiz Quiz ▪ For the quiz we are performing not operations ▪ Use the data present the file ▪ Show all those documents where name is not ab or qty is not 15 or size is 15 ▪ Show all those documents where tags do not contains D or C or name is not ab ▪ Show all those documents where code is not 123 or qty is greater than 15 or tags do not contains A or D ▪ Show all those documents where