0% found this document useful (0 votes)
14 views49 pages

WDF Unit 3 QB & Study Material

Uploaded by

keerthikt10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views49 pages

WDF Unit 3 QB & Study Material

Uploaded by

keerthikt10
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 49

UNIT-3: MONGODB

2 marks
1, what are the key Characteristics of NOSQL databases?
The key characteristics of NOSQL databases are as a follows:
• Schema-less structure
• Horizontal Scalability
• High performance Scalability
• Flexible Data Models
• Distributed and Decentralized Architecture
• Big Data and Unstructured Data Support
• Developer Productivity
2, How does MongoDB fit in to the NOSQL paradigm?
Following are the key features how MongoDB fit into NOSQL are
• Document Oriented Data Model
• Dynamic Schema
• Horizontal Scalability
• High Performance and Availability
• Flexible Queries
• Integration with modern Technologies
• Wide Range of use cases
3, How do you set up a MongoDB environment for development, and what are the essential steps
involved?
• Install MongoDB
• Start MongoDB
• Connect to MongoDB
• Create a Database
• Create collections and Documents
• Perform CRUD operations
4, List out the method used for CRUD Operations?
Method Description
db.collectionName.insertOne(document) Insert a single document into a collection
db.collectionName.find() Retrive all documents from a collection
db.collectionName.updateOne(filter,update) Update a single document in a collection
db.collectionName.deleteOne(filter) Delete a single document from a collection

5. Explain the concept of user accounts in MongoDB


• User accounts in MongoDB are created to associate a username and password with a specific set
of privilages or roles
• Each user account is created within a specific database and by default , user accounts are stored in
the admin database.
• User accounts can be assigned roles that determine the level of access and permission they have
within the database
6. Explain authentication mechanism in mongo DB

• Mongo DB Supports authentication mechanism to verify the identity of users attempting to access
the database
• The most commonly used authentication mechanism is SCRAM salted challenge response
authentication mechanism which is a secure and password based authentication mechanism.
• Additionally mango DP supports authentication like kerberos,x.509 certificate ldap and more
allowing integration with external authentication systems.
7. Explain about Access control in MongoDB.
• Access control in mango DB is managed using roles and privileges
• Their role is a set of privileges that define the actions are user can perform within a database or on
specific resource example collections.
• Mango DB provide several built in roles such as read, readwrite, DB admin, user admin, and more,
each with different levels of access.
• Custom roles can also be created to defines specific set of privileges tailed to the application
requirement.
8. List some of the best security practices in mango DB
• Enabling access control to require authentication for all connections
• Using strong and unique passwords for user accounts
• Limiting user privileges to the minimum required for their task
• Regularly monitoring and reviewing user access and privileges
• Enabling network encryption using SSL/TLS two Secure data in transit
9. What are the key responsibilities and task involved in administrative mango db database?

• Installation and configuration


• Security and access control
• Backup and recovery
• Performance Optimisation
• Monitoring and alerting
• Capacity planning and scaling
• Ocean upgrades and patching
• Database monitoring And maintenance
• Disaster recovery planning
• Documentation and documentation
10. How do you manage collections within mango db
• As data grows managing collections size becomes important. This can include Tower such as
monitoring disk space usage, conjuring data archival or data purging strategies, and optimizing
storage options based on the data growth patterns.
• By efficiently managing collections, you can ensure efficient data organisation, optimise query
performance, and maintain the integrity and availability of your data within mango DB.
11. What is the process involved in collection
• Creating collection
• Viewing collection
• Renaming a collection
• Dropping a collection
• Modifying a collection
• Indexing a collection
• Monitoring collection statistics
• Modifying collection options
• Monitoring and optimising collection performance
• Managing collection size
12.What are the best practices for organizing and structuring data?
when organising and structuring data in mango db, its important to follow best practices to ensure efficient
querying, maintainability and scalability.
Here are some best practices for organising and structuring data in mango DB.
• Identify the key entities
• Use embedded data models
• Normalise data when appropriate
• De normalise for query performance
• Design indexes carefully
• Free aggregate data for performance
• Avoid Excessive Nesting
• Plan for Data Growth and Scalability
• Leverage MongoDB's Document Validation
• Regularly Review and Refactor Data Model

13. What are the recommended libraries or drivers to connection between Node.js and MongoDB?
• MongoDB Node.js Driver (Official Driver)
• Mongoose
• MongoDB Atlas
• Monk
• MongoDB Memory Server
• These libraries/drivers offer different levels of abstraction and functionality, so the choice depends
on your specific needs and preferences.
• The official MongoDB Node.js Driver is the most comprehensive and flexible choice, while
Mongoose provides additional features for data modeling.
• Monk and MongoDB Memory Server are lighter options if you prefer a simpler and more
lightweight approach.
14. What are the security considerations and best practices for ensuring the integrity and confidentiality of
data stored in MongoDB?
Some security considerations and best practices to follow when working with MongoDB:
• Authentication and Authorization
• Network Security
• Encryption at Rest
• Auditing and Logging
• Secure Configuration
• Regular Patching and Updates
• Secure Development Practices
• Regular Security Assessments and Penetration Testing
• User Education and Awareness
• Compliance and Regulations
15. How does MongoDB handle scalability and high availability in distributed environments
MongoDB provides several features and mechanisms to handle scalability and high availability in
distributed environments. Here are some key features MongoDB offers
• Sharding
• Replica Sets
• Automatic Failover
• Read Preference and Read Concern
• Distributed Transactions
• Zone Sharding
• MongoDB Atlas and Cloud-Based Deployments
• Ops Manager and Monitoring
MongoDB Ops Manager is a management platform that provides monitoring, automation, and backup
capabilities for MongoDB deployments.
Ops Manager helps monitor the health and performance of your distributed MongoDB environment,
allowing you to proactively address issues and ensure high availability.
By leveraging these features and capabilities, MongoDB enables scalability and high availability in
distributed environments. Whether through sharding to distribute data across multiple nodes, replica sets
for fault tolerance and failover, or distributed transactions for maintaining data integrity, MongoDB
provides robust tools for building scalable and highly available systems.

16. What techniques can be employed to optimize performance?

To optimize performance in MongoDB, you can use techniques such as


• indexing
• query optimization
• proper data modelling
• connection pooling
• caching
• hardware optimization
• monitoring
• performance tuning
• schema design review and
• profiling/performance testing.
17. List out the benefits of using MongoDB as a database solution compared to traditional relational
databases?
• The benefits of using MongoDB compared to traditional relational databases are its
• flexible data model
• high performance
• scalability
• NoSQL capabilities
• easy development and integration
• horizontal read scalability
• automatic failover and data redundancy
• vibrant community and ecosystem
flexibility in deployment and
• enterprise-grade security.

18. What are the options of show syntax in Mongolth?


show <option>: Shows a list based on the option argument. The value of option can be:
• dbs: Displays a list of databases.
• collections: Displays a list of collections for the current database.
• profile: Displays the five most recent system.profile entries taking more than 1 millisecond.
• databases: Displays a list of all available databases.
• roles: Displays a list of all roles for the current database, both built-in and user-defined.
• users: Displays a list of all users for that database.

19. Write about creating the Administrator User for all database.

✓ Creating a User Administrator account is done by executing following two commands in MongoDB shell to
access the admin database and then add a user with userAdminAnyDatabase rights.
• S y n t a x:
use admin
db.createUser(
{ user: `"',
pwd: `"',

roles: { "userAdminAnyDatabase"]
})

✓ User Administrator account should be created with userAdminAnyDatabase as only' role.


• This gives User Administrator ability to create new user accounts but not to manipulate database
beyond that.
For example,

use admin
db.create user(
{ user: "sriram'',
pwd: "sriram",
roles: [ "userAdminAnyDatabase”l
} )

20. Write down the syntax on the Database operations.


Displaying a List of Databases:
show dbs

• Displays a list of databases that have been created.


• Changing the Current Database
db = db.getSiblingDB(`testDB') or
use testDB
• Creating Databases
• You can simply use the "use <Data base>" to create a new database handle and add a collection to it.
use newDB db.createCollection("newCollection")

• Deleting Databases
use newDB
db. dropDatabase( )
• Copying Databases
• Copying a database creates an exact duplicate of database, only with a different name.
copyDatabase(origin, destination, [hostname j)
• The optional hostname parameter specifies a hostname of origin database
MongoDB server if you are copying a database from a different host.

21.List the features of MongoDB


Ans
1) It is a schema-less, document based database system.
2) It provides high performance data persistence.
3) It supports multiple storage
engines. 4)It has a rich query
language support.
5) MongoDB provides high availability and redundancy with the help of
replication.That means it creates multiple copies of the data and sends these
copies to a different server o that if one server fails, then the data is retrieved
from another server.

22.What is Map reduce?


Map reduce is a data processing programming model that helps in
performing operations on large data sets and produce aggregate results Map
reduce is used for large volume of data.
The syntax for map reduce is
db.collection.mapReduce(
function() {emit(key,value);}, //map function function(key,values) {return
reduceFunction}, { //reduce function
out: collection,
query: document, sort:
document, limit: number
}
)

Where

1) map function: It uses emit() function in which it takes two parameters


key and value key. Here the key is on which we make groups(such as group
by name, or age) and the second parameter is on which aggregation is
performed like avg(), sum() is calculated on.

2) reduce function: This is a function in which we perform aggregate


functions like avg()sum()

3) out: It will specify the collection name where the result will be stored.

4) query: We will pass the query to filter the resultset.

5) sort: It specifies the optional sort criteria.

6) limit: It specifies the optional maximum number of documents to be returned.


16 Marks

1. Write about Data Model planning for MongoDB.


2. Brief about MongoDB basics.
3. How will you build a MongoDB environment.
4. Explain in detail about Access control of MongoDB.
5. List the step-by-step process to User accounts and Administering the Databases.
USER ACCOUNTS
6. How to Managing collections in MongoDB.
7. Describe step by step process to Connecting to MongoDB from Node.js.
8. Generate the Simple Applications using Node.js and MongoDB CRUD Operation for Student mark details.

You might also like