mongodb basics class 11

Basics Of NoSQL Database – MONGODB class 11

mongodb basics

Q 1. What were the needs and requirements that led to development of NoSQL database ?

cbse class 11 computer science notes 2021


ans. Today’s web, mobile, and IOT applications share one or more of the following characteristics. They need to :
1. Support large numbers of concurrent users (tens of thousands, perhaps millions)
2. Deliver highly responsive experiences to a globally distributed base of users
3. Be always available – no downtime
4. Handle semi-structured and unstructured data
5. Rapidly adapt to changing requirements with frequent updates and new features

Q 2. What are the main categories of NoSQL database ?


ans. The NoSQL data are following four types :


(i) Key-value stores. These databases pair keys to values where the key is the unique identifier and the data is stored in the form of values.


(ii) Graph stores. These excel at dealing with interconnected data. Graph databases consist of connections, or edges, between nodes. Both nodes and theiredges can store additional properties such as key-value pairs.


(iii) Document stores. These databases store records as “documents” where a document can generally be thought of as a grouping of key-value pair (it has nothing to do with storing actual documents such as a word document). Keys are always strings, and values can be stored as string, numeric, Booleans, arrays, and other nested key-value pairs.


(iv) Column family stores. Column store database is a type of database that stores data using a column oriented model. These databases use a special type of schema that contains column families.

Q 3. Create a database namely pet shop in MongoDB having a collection pets in it. Add following documents in it :
1. name : “Bruno”, species : “Gerbil”
2. name : “Teekha”, species : “Piranha”
3. name : “Tezi”, species : “Cat”
4. name : “Bruno”, species : “Hotdog”
5. name : “Anjan”, species : “Shepherd”
6. name : “Rakshu”, species : “Cat”


ans.
use petshop
1. db.pets.insert({name: “Bruno”, species: “Gerbil”})
2. db.pets.insert({name: “Teekha”, species: “Piranha”})
3. db.pets.insert({name: “Tezi”, species: “Cat”})
4. db.pets.insert({name: “Bruno”, species: “Hotdog”})
5. db.pets.insert({name: “Anjan”, species: “Shepherd”})
6. db.pets.insert({name: “Rakshu”, species: “Cat”})

Q4. Add another piranha, and a naked mole rat called Chhutku.


ans.
db.pets.insert({name: “Offo”, species: “Piranha”})
db.pets.insert({name: “Chhutku”, species: “Naked Mole Rat”})

Q 5. Use find to list all the pets.


ans. db.pets.find()

Q 6. Find the ID of Bruno the Gerbil. Display only the id


ans. db.pets.find({name: “Bruno”, species: “Gerbil”}, {_id : 1})

Q 7. Use find all the gerbils.


ans. db.pets.find({species: ‘Gerbil’})


Q 8. find all the creature named Bruno. Display details without id.


ans. db.pets.find({name: ‘Bruno’}, {name: 1, species: 1, _id :0})

Q 9. Find all the creatures Bruno who are gerbils.


ans. db.pets.find({name: ‘Bruno’, species: ‘Gerbil’})


Q 10. Update the species Cat with “Meau Cat”.


ans. db.pets.update({species: “cat”}, {$set : {species : “Meau Cat”}})

mongodb basics

How to learn python programming for beginners ?