Mongodb
Mongodb
Answer:
Answer:
Relational database are invented in 1970s to that make possible to store data in the form of table which is
combination of row and columns.
To communicate with relational database a language called SQL was introduced & almost all relational database
system use SQL.
SQL is more rigid to work with unstructured data.
Evolution of NOSQL:
To acronym NoSQL was first used in 1998 by Carlo Strozziwhile naming his lightweight, open-source “relational”
database that did not use SQL.
Carlo Strozzi suggests that ,because the current NoSQL movement “departs from the relational model
altogether, it should therefore have been called more appropriately ‘NoREL’—referring to ‘No Relational’.
The name came up again in 2009 when Eric Evans and Johan Oskarsson used it to describe non-relational
database.
Johan Oskarsson, then a developer at Last.fm, reintroduced the term NoSQL in early 2009 when he organized an
event to discuss “open Source distributed, non-relational database”.
Answer:
1. SQL Stands for Structure Query Language. NOSQL Stands for Not Only SQL.
2. SQL is a query language that used to There is no declarative query language to communicate with
communicate with relational database. database.
3. SQL database are primarily called RDBMS or NoSQL database are primarily called as non-relational or
relational database. distributed database.
4. SQL or relational database stores structure NOSQL database deals with semi-structure & unstructured
oriented data. data.
5. Traditional RDBMS uses SQL syntax and queries NoSQL database system consists of various kind of database
to analyze and get the data for further use. technologies that developed in response to the demand
presented for the development of the modern application.
6. SQL database are Table based database. NoSQL database can be document based, key-value pairs,
graph database.
7. SQL database Have a predefined schema. NoSQL database use dynamic schema for unstructured data.
8. SQL database are vertically scalable. NoSQL databases use dynamic schema for unstructured data.
9. An ideal choice for the complex query intensive It is not good fit complex queries.
environment.
10. SQL database are not suitable for hierarchical More suitable for the hierarchical data store as it supports
data storage. key-value pair method.
11. It was developed in the 1970s to deal with issues Developed in the late 2000s to overcome issues and
with flat file storage. limitation of SQL database.
12. Most of RDBMS systems are proprietary. Most of NoSQL systems open-source.
13. It should be used when data validity is super Use when it’s more important to have fast data than correct
important. data.
14. Examples: Oracle, Postgres And MS-SQL. Example: MongoDB, Redis, Neo4j, Cassandra, Hbase.
Answer:
3. Open source
- NoSQL is an open source so its software’s are easily available on internet.
4. Free of joins
- NoSQL system allows you to extract your data using simple interfaces without joins.
5. Schema-free
- In NoSQL system user do not need to define schema for data because it is schema free.
6. Work on many processors
- NoSQL system allows you to store your database on multiple processors and maintain high-speed
performance.
7. Less cost
- NoSQL database is less expensive for storage and transactions.
8. Linear scalability
- Huge amount of data can store on NoSQL database.
- When you add more processors, you get a consistent increase in performance.
9. Innovative
- NoSQL offers option to a single way of storing, retrieving, and manipulating data.
10. Highly distributable
- NoSQL uses the powerful, efficient architecture instead of the expensive single architecture that make
possible to distribute data very fast & efficiently.
11. Continues availability
- A database server can stay online as well as offline.
- Users can also use server 24*7 so server may continues available.
12. Non-relational
- The information in NoSQL is stored in the form aggregate.
- A single record stores every information about the transaction, including the delivery address.
Disadvantages:
Answer:
Answer:
Advantages:
Disadvantages:
Advantages:
Disadvantages:
Advantages:
- Easy to understand.
- Easy to represents highly connected data.
- Provide index free architecture
- Flexible schema
- Suitable for real-time update big data
- Support relational data
Disadvantage:
Advantage:
Disadvantages:
Answer:
- When a database is stored in a local pc or stand-alone pc then it is called local hosted database.
- This type of database is local to your application only, so that it is stored on the pc where application is
resides.
- This type of database uses SDF file format (Single Data File).
- If you want to publish your database over the internet then locally hosted database will be used.
- It’s limited for authorized users only. A user doesn’t know where the data is physically located users can
access it.
- It is basically maintain by system administrator.
- A database can be accessed over different network.
- The main advantage of this system is you have complete control over data because data is stored on local
server.
Advantage:
Disadvantages:
Answer:
Answer:
- MongoDB is a document-oriented NoSQL database used for high volume data storage.
- MongoDB is an open source document based NoSQL database that can install on different platform like
windows, Linux etc.
- MongoDB is a non-relational database.
- It is a cross-platform, document oriented database that provides, high performance and easy scalability.
- Relational database have a fixed data structure while MongoDB is a schema free.
- In MongoDB data is stored in the form of JSON style document.
- Main purpose to build MongoDB is:
1. Scalability
2. Performance
3. High Availability
- MongoDB is suitable for the following application:
1. Big Data
2. Content management and delivery
3. Mobile and social infrastructure
4. User data management
5. Data Hub
- MongoDB works on concept of
1. Database
2. Collection
Answer:
9. Indexing:
- Indexes can be created to improve the performances of searches with in MongoDB.
10. Replication:
- MongoDB supports master slave replication.
- A master can perform reads and writes and s slave copies data from the master and can only be used for
reads or backup.
11. Duplication of Data:
- MonogoDB can run over multiple servers.
- The data is duplicated to keep the system up and also keep its running condition in case of hardware failure.
OR
1. Database:
- Database is a physical container for collection.
- Each database gets its own set of files on the system.
- A single MongoDB server typically has multiple databases.
- In MongoDB, database holds collection of documents.
- A MongoDB, server can store multiple databases.
2. Collection:
- Collection is a group of MongoDB document.
- It is equivalent of an RDBMS table.
- The data records are BSON document stored in collection inside a database.
- BSON stand for Binary JSON.
- Collections stores document.
- Documents are the unit of data stored in collection.
- A collection exists within a single database.
- Documents within a collection can have different fields.
- All documents in a collection are of similar or related purpose.
3. Document:
- A record in a MongoDB collection is basically called a document.
- Documents are the unit of data stored in collections.
- Documents have a dynamic schema.
- MongoDB document are composed of field-and-value pairs and have the following structure:
{
Field1: value1,
Field2: value2,
Field3: value3,
………
Fieldn: valuen,
}
Answer:
- First check the operating system architecture by placing following command in cmd
- MongoDB require a data directory to store all data; MongoDB’s default data directory path is \data\db.
- To configure this go to your c:drive and create data\db folder (“db” folder inside “data” folder)
So now full path of db folder will be-C:\data\db
- Now open cmd& type go to MongoDB directory.
C:\users\stud\ cd C:\program files (x86)\MongoDB\server\3.0\bin
- Now run MongoDB method MongoDB server has been started on port – 27017
- Now open another cmd prompt and type mongo.
- This shows that you have been connected with MongoDB server.
- Now you can perform all MongoDB commands.
Answer:
- MongoDB contains flexible schema or schema-less, which means there is no need of defining a structure for
the data before insertion.
- MongoDB is a document based database, in which any document stored in collection.
- Collection in MongoDB doesn’t enforce the document structure.
- In general, the documents in a collection of MongoDB will always share the same data structure
(recommended for best performance, not mandatory)
- The dynamic schema required high data balancing of application and performance characteristics of
database engine.
- During designing of data model always consider the application usage of data such as queries, update and
processing of data as well as structure of data itself.
- There are two tools in MongoDB that represent the relationship between data.
1. Reference Document
2. Embedded Document
Question 14: What is Query? What are the types of Query document in MongoDB?
Answer:
OR
Answer:
1. Create database
- Syntax:
Use <DATABASE_NAME>
- USE command is used to create a database in MongoDB.
- The command will create a new database; if it doesn’t exit otherwise it will return the existing database.
- Example:
>use student
2. Display database
db command
- Syntax:
db
- To check your currently selected database use the command db
Show dbs:
Syntax:
- Show dbs
- This command used to display all database created by user.
3. Delete database
Syntax
- db.dropDatabase()
- To remove database from MongoDB use db.dropDatabase ().
- This will delete the selected database.
- Before delete any database first use database with its name.
- If you have not selected any database, then it will delete default ‘test’ database.
Answer:
Option Document (optional) Specify options about memory size and indexing
- syntax:
show Collections
- MongoDB allows you to display all collection by using show collection method.
- This method list out all collection created in currently used document.
- EXAMPLE:
> show collections
- syntax:
db.collection_name.drop()
- MongoDB allows you to remove collection.
- To remove collection drop() will be used.
- After delete the collection method will return true, if the selected collection is not delete successfully then
MongoDB return false.
- for example:
> show collections
> db.student.drop()
- syntax:
db.collection.renameCollection(target)
- MongoDB allows you to rename collection by using db.collection.renameCollection method.
- In syntax: Target specifies the new name of collection.
- EXAMPLE:
> db.student.renameCollection(“stud”)
- syntax:
db.collection.copyTo(target)
- MongoDB allows you to copy collection by using db.collection.copyTo().
- copyTo() returns the number of documents copied. If the copy fails, it throws an exception.
- In syntax: Target specifies the new name of collection.
- EXAMPLE:
> show collections
student
> db.stud.copyTo(“student”)
- syntax:
db.collection.storageSize()
- syntax:
db.collection.dataSize()
- MongoDB allows you to view the size of collection by using db.collection.dataSize()
- dataSize() return The size in bytes of the collection.
- EXAMPLE:
> show collections
> db.student.dataSize()
- Output: 336
Answer:
2. insertOne():
- syntax:
db.collection_name.insertOne()
- insertOne () command to insert a single documents into a collection.
- This method is available with MongoDB version 3.2 or newer version launch after 3.2
- After insert document in collection this method return unique ID of the document.
})
3. insertMany():
- syntax:
db.collection_name.insertMany(,…..)
- insertMany () command to insert a multiple documents into a collection.
- This method is available with MongoDB version 3.2 or newer version launch after 3.2
- After insert document in collection this method return unique ID of the each document.
- This ID can be used to find document from collection.
- EXAMPLE:
> use student
> db.stud.insertMany(
{
"rlno" : 1,
"name": "meghna"
},
{
“rlno”:2,
“name”:”ekta”
})
Answer:
Answer:
- update ():
- syntax: db.collection_name.update (selection_criteria, updated_data)
- Update () is used to update existing data stored in document.
- We need to specify selection criteria for update a document & then update data using $set keyword.
- In this section you have to specify the field along with value
Answer:
- There are several operators used with update command which is divided into two parts:
1. Field update operator
2. Array update operator
Field update operator
- Field update operators are basically used to update fields.
- Following are field update operators:
1. $set:
- Syntax: { $set: { : , ... } }
- This operator used to set new value in a field/key.
- Parameters:
Name Description
Value The value, specified against a field for an expression, or condition, or matching criteria.
Addition The value of to be added for a field or column into an array if this value not exists.
- EXAMPLE: documents contain 4 subject marks & rlno 5 contain 3 marks want to add marks in array
>db.stud.update({rlno:5},{$addToSet: {marks:55}})
2. $pop
- Syntax: db.collection.update( {field: value }, { $pop: { field: [1 | -1] } } )
- $pop operator removes the first or last element of an array.
- -1 is used to remove the first element of an array
- 1 is used to remove the last element.
3. $pull
- syntax :{ $pull: {<field1> :<value|condition>,<field2>:<value|condition>,…} }
- The $pull operator removes from an existing array all instances of a value or values that match a specified
condition.
- parameters:
Name Description
Value, value1, value2, … These are the values to be specified for the fields or columns.
- EXAMPLE
>db.alpha.update({id:111},{$pull:{text: {$in:["aa","e","h"]}}})
4. $pullAll
- syntax:{ $pullAll: { field1: [ value1, value2, value3 ] } } )
- The $pullAll operator is used to remove multiple values specified with $pullAll operator.
- It is similar to $pull operator
- Parameters:
Name Description
Value, value1, value2, … These are the values to be specified for the fields or columns.
- EXAMPLE:
>db.alpha.update({id:111},{$pullAll:{text: ["bb","g"]}})
5. $push
- This operator used to insert element in array. Generally $push insert element at the end of an array.
- by using $push we can
1. push from the start of an array
2. push from the end of an array
3. push multiple elements at once
4. push at any location to an array
Answer:
1. REMOVE DOCUMENTS
Remove ()
- syntax:db.COLLECTION_NAME.remove(DELLETION_CRITTERIA, justone)
- Remove () method is used to remove a document from the collection.
- By using this command we can delete a single document or all document stored in collection.
- Remove () method accepts two parameters.
- after performing deletion MongoDB display message along with a number that specify total no of document to
be deleted
Deletion _criteria - Specify criteria for delete document.
- MongoDB's deleteOne() method is used to remove a single document from the collection.
- by using this command we can delete a single document that match specific criteria.
- EXAMPLE:
- DELETE ONE DOCUMENT FROM STUD COLLECTION WHO ARE IN MCA.
> use college
> db.stud.deleteOne({streem:"MCA"})
3. DELETE MULTIPLE DOCUMENTS deleteMany ()
- syntax: db.collection_name.deletemany(delletion_critteria,writeconcern)
Deletion _criteria - Specify criteria for delete document.
- MongoDB's deleteMany () method is used to remove a more than one document from the collection.
- by using this command we can delete multiple documents that match specific criteria
- EXAMPLE:
- DELETE DOCUMENTS FROM STUD COLLECTION WHO ARE IN MCA.
> use college
> db.stud.deleteMany({streem:"msc.it"})
Answer:
Binary Data “bindata” 5 These MongoDB data types store the binary data in
it.
Object id “objected” 7 This data type in MongoDB stores the unique key Id
of documents stored
Javascript “javascript” 13 These MongoDB data types store the JavaScript data
without a scope.
Symbol “symbol” 14 These MongoDB data types similar to the string data
type.
Javascript with scope “javascriptwithScop” 15 These MongoDB data types store JavaScript data
with a scope.
Min key “minkey” 255 Min key compares the value of the lowest BSON
element.
Max key “maxkey” 127 Max key compares the value against the highest
BSON element.
Answer:
$eq Matches values that are equal to a specified value. { key :{ $eq :value } }
$gt Matches values that are greater than a specified value. { key :{ $gt :value } }
$lt Matches values that are less than a specified value. { key :{ $lt :value } }
$gte Matches values that are greater than or equal to a specified value. { key :{ $gte :value } }
$lte Matches values that are less than or equal to a specified value. { key :{ $lte :value } }
$ne Matches values that are not equal to a specified value. { key :{ $ne :value } }
$in Matches any of the values specified in array. { key :{ $in :value } }
$nin Matches none of the values specified in an array. { key :{ $nin :value } }
2. LOGICAL OPERATOR:
- This operators are used to compare the values & display document that match specified criteria.
$and returns all documents that match the conditions of both { $and: [ {<exp1> }, {<exp2> } , ... , {<expN } ] }
expression becomes true
$not Returns documents that do not match the query {field: {$not: [ {operator-expression> }}}
expression.
$or returns all documents that match any one or all the { $or: [ {<exp1> }, {<exp2> } , ... , {<expN } ] }
conditions of both expression becomes true
$nor returns all documents that fail to match both clauses. { $nor: [ {<exp1> }, {<exp2> } , ... , {<expN } ] }
Answer:
- In Mongo DB we got query modifiers such as the 'limit' and 'Orders' clause to provide more flexibility when
executing queries.
- This modifier allows users to perform external functionality to retrieve data.
- MongoDB provides three modifiers:
1. Limit()
- Syntax: db.collection_name.find().limit(number_of_documents)
- Limit () provides the limitations of documents to be displayed in MongoDB.
- This method specifies that how many number of documents that you want to display in output.
- Using limit() method to limit the documents in the result
- It is used with find () command.
- In syntax Number of documents specifies number of document to be display as an argument of limit ().
- EXAMPLE:
>db.stud.find().limit(3).pretty()
Answer:
CREATE INDEX
ensureIndex():
- syntax: db.collection_name.ensureIndex({key : 1 })
- This command used to create index in MongoDB.
- Specify a fieldname on which you want to create index as a key.
- You can create index on one or field in MongoDB.
- Use 1 to arrange index field in ascending order & -1 for descending order.
- EXAMPLE:
>db.m.ensureIndex({no:1})
createIndex():
- syntax: db.collection_name.createIndex({key : 1 })
- This command used to create index in MongoDB.
- It works similar to ensureIndex command.
- You can create index on one or field in MongoDB.
- Use 1 to arrange index field in ascending order & -1 for descending order.
- EXAMPLE:
>db.m.createIndex({no:1})
- getIndexes():
- syntax: db.collection_name.getIndexes()
- This command used to display index generated by users in MongoDB.
- EXAMPLE:
>db.stud.ensureIndex({per:1})
>db.stud.getIndexes()
REMOVE INDEXES
- dropIndex():
- syntax: db.collection_name.dropIndex({key:1})
- This command used to remove index generated by users in MongoDB.
- EXAMPLE: >db.stud.dropIndex({per:1})
- Execute ()
- By using execute () method we can show execution states.
- To show how many documents are examine by MongoDB to find any document use executeStatus()
- EXAMPLE:
- Want to display all documents where per > 50 & see how many documents examine by MongoDB to perform this
query.
>db.stud.ensureIndex({per:{:$gt:50}}). Explain (“executionStats”)
Answer:
2. REFERENCES DOCUMENTS:
Answer:
Answer:
- Session support in PHP consists of a way to preserve certain data across subsequent accesses.
- A visitor accessing your web site is assigned a unique id, the so-called session id.
Session_start() Start session
Answer:
- Session Management implements the exchange mechanism between the user and the application.
- The session id is used for remember the user in application or in web application.
- There are many different frameworks which provide their own session management features like J2EE, Asp.Net,
and PHP etc.
- There are different frameworks available for session management which have its own advantages and
disadvantages.
- MongoDB Atlas provides all the features that have made the monogodb as NO SQL database.
- It provides data model flexibility, scalability & combine them with optimizations
- Session Manager is a simple powerful extension that makes it quick and easy to save, update, remove, and
restore sets of tabs in any browser.
- In PHP session management will be performed by different functions.
- A session is a way to store information (in variables) to be used across multiple pages.
- Session variables remains until the user closes the browser.
- A session is started with the session_start() function.
- Session variables are set with the PHP global variable: $_SESSION.
- The session_set_save_handler() function allows us to define our own functions for storing and retrieving session
data.
Answer:
Answer:
Answer:
- Aggregation basically groups the data from multiple documents and returns one combined result.
- When we want to perform operation in group of field then aggregation will be use.
Answer:
$avg It calculates the average values from all the documents in the collection.
$addToSet It is used to Insert values to an array but no duplicates in the resulting document.
$first Return the first document from the source document that match group field
$last Return the last document from the source document that match group field.
Answer:
- String expression are use to perform operation on textual data stored in field.
- We can use string expression with $project stage of aggregation pipeline.
- Some string aggregation operators are:
1. $concat
- This operator is used to merge two or more string
- Syntax: { $concat: [<expression1>,<expression2> , ... ] }
2. $substr
- This operator is used to retrieve string from existing string.
- When we want to retrieve some specific part of string then $substr will be used.
- Syntax: { $substr: [ “expression”,<start> <end>, ] }
3. $toUpper
- $toUpper operator used to convert fields values in uppercase & $lower is used to convert fields value in lower
vase
- Syntax: { $toUpper| $toLower:<”expression”> }
4. $toLower
- This operator is used to find out length of string in bytes
- Syntax: { $strLenBytes:<expression> }
5. $strLenBytes
- This operator is used to compare two string & return a number either 1 , 0 or -1
- if string1 > string2 then return 1
- if string1 < string 2 then return -1
- if string1 and string 2 are equal then return 0
- Syntax: { $strcasecmp:[$str1,$str2] }
6. $strcasecmp
- This operator is used to split a string according to specified delimiter
- Delimiter is any character or symbol
- Syntax: { $split: [<string expression>,<delimiter> ] }
Answer:
Answer:
- Syntax:
db.collection.mapReduce(
function() {emit(key,value);}, //map function
function(key,values) {return reduceFunction},
{
out: collection,
query: document,
sort: document,
limit: number
})
Answer:
- Analzing data is the process where we filter out result from external data & produce a proper result.
- Any business contain large amount of data then MongoDB provides a solution that fulfill the needs of users.
- Monogdb provides an ideal operational database that provides high performance, storage & retrieval of large
scale data.
- There are three categories to extract analysing data
1. Using aggregation
2. Using Map-Reduce
3. Using shared collections
Aggregation / aggregation pipeline
- The aggregation pipeline is a framework for data aggregation which is formed on the concept of data processing
pipelines.
- Documents enter a multi-stage pipeline that transforms the documents into aggregated results.
- There are various stage of aggregation pipeline like $project, $match, $group, $sort , $limit and $unwind
Using map reducing
- Map-reduce is a data processing paradigm for condensing large volumes of data into useful aggregated results.
- Map reduce performed by two functions: o Mapper o reducer
- In map reduce MongoDB extract all from database using Map function & then merge the data which has same
key.
- The map function emits key-value pairs.
- Then it reduce the external data by using reduce function.
Shared collections
- Sharding is a method for distributing data across multiple machines.
- MongoDB uses sharding to support deployments with very large data sets and high throughput operations.
Answer:
0 No logging
F Fatal
E Error
W Warning
I Informational
Answer:
- MongoDB provides facility to analyze data at any place with fast real time & an less money.
- Most of companies use analytics on real time so analytics must be support simple and faster query retrieval.
- Companies use many applications for complex and long running analysis of data but these applications have
slower response time and lower requirements.
- Real time analytics is hard for Relational databases that aren’t capable of handling unstructured and semi-
structured data.
- Batch processes are the right approach for some jobs.
- MongoDB can incorporate any kind of data – any structure, any format, any source – no matter how often it
changes.
- MongoDB is built to scale out on commodity hardware.
- MongoDB can analyze data of any structure directly within the database.
- MongoDB is used for realtime analytics data in an area such as financial service, government services, high tech
& retail sevices.
1. Financial Service:
- It includes area like risk analytics & reports, Reference Data Management, Market Data Management
2. Government:
- Many government service providers use MongoDB including City municipal services, National defense and
intelligence agencies, Civilian agencies in healthcare, finance, energy, and more.
3. High tech Service:
- In the most competitive industry of all, tech innovators are using MongoDB to do things they could never do
before. Faster. With Less Money.
Answer:
- GridFS is the file system which is use to storing and retrieving files.
- GridFS is a way through which we can store and retrieve large files such as audio files, video files, images, etc. in
MongoDB.
- GridFS is a file system of MongoDB but the data of files are stored within MongoDB collections.
- MongoDB GridFS is used to store and retrieve files that go above the BSON document size limit of 16 MB.
- GridFS divides the file into small parts called as chunks.
- Each chunk is stored as a separate document.
- The default size for a chunk is 255kb for all chunks except the last one, which can be as large as necessary.
- MongoDB GridFS uses two collections to store files.
- One is used to store the file chunks and the second one to store file metadata.
- Collections are:
1. File collection fs.files
2. Chunks collectionfs.chunks
The files collection
- This collection is used to store only metadata information of file.
- It represents information about file along with id, length, name & Metadata.
- Use db.fs.files.find() to access files collections.
The chunks collection
- Chunk is small part of file. Chunks collection stores all documents in small parts.
- Default size of each chunk is 255kb so it is possible that one file will divide into multiple chunks.
- db.fs.chunks.find() used to display chunks detail.
ADVANTAGES GRIDFS:
- Allows you to storing large number of files.
- Support many types of format in storing files.
- Provides metadata information of every file
DISADVANTAGES OF GRIDFS:
- Not allowed to update the content of entire file.
- GridFS does not provide a way to do an atomic update of a file.
- The file serving performance will be slower than natively serving the file from your web server and file system.
Answer:
- mongoFiles is a command which is used to store, delete , update & display files stored in GridFS objects.
- Using this command GridFS can store any type of file.
- This command serves as an interface between objects stored in your file system and GridFS.
- SYNTAX:
Mongofiles <options> <commands> <filename>
Options:
- Specify option to connect with MongoDB database. You can use following options:
--local It Specifies the local filesystem name of a file for put and get operations.
--replace Alters the behavior of mongofiles put to replace existing GridFS objects with the
specified local file
Commands:
- Specify command to perform operations. We can use commands like:
Put <filename> Copy the specified file from the local file system into GridFS storage.
Get <filename> Copy the specified file from GridFS storage to the local file system.
Search <string Lists the files in the GridFS store with names that match any portion of <string>
Question 42: How To Storing, Serving & Reading File With Gridfs?
Answer:
- Mongofiles command is used to perform different operation with grideFS like storing and retrieving files from
local system to grideFS.
- To use GridFS we have to open separate commander window & execute mongofiles command.
- Mongofiles include following commands.
list
- SYNTAX: mongofiles –d <dbname> list
- It will display the file list of mongo connected to local host.
- It also display the size of file.
- EXAMPLE:
mongofiles –d STUD list
Put
- SYNTAX: mongofiles –d <dbname> put <filename>
- If you want to add or store the file into gridefs then put command is used.
- You can store different types of files like text files, image file, mp3, etc…
- EXAMPLE:
mongofiles –d STUD put myfile.txt
get
- SYNTAX: mongofiles –d <dbname> get <filename>
- The get command is used to retrieve the file from grideFS to the local system
Plazma Institute Page 36
NoSQL DATABASE: MONGODB
- This command can't display content of file directly.
- EXAMPLE:
mongofiles –d STUD get myfile.txt
delete
- SYNTAX: mongofiles -d <dbname> delete<filename>
- If you want to delete a file of grideFS then you have to use the delete command in the mongofiles command
prompt.
- EXAMPLE:
mongofiles –d STUD delete myfile.txt
Search
- SYNTAX: mongofiles -d <dbname> search <string>
- Lists the files in the GridFS store with names that match any portion of.
- EXAMPLE:
mongofiles –d STUD search xyz
Answer:
- Above figure shows 3 members replica set that contain 1 primary instance and 2 secondary instances.
- When a primary instance receives a write operation from a user then it updates its oplog (operation log).
ADVANTAGES:
- We can keep the data safe.
- Ensure the high availability of data
- We can take care of disaster recovery
- No downtimes required for maintenance
- Replica set is always transparent to the application.
Answer:
Answer:
Answer:
Answer:
- Administration include ongoing & maintenance of MongoDB instance & its deployment.
- Administration is used to keep track & control on database & its resources.
- The database administration provides the operation and maintains of MongoDB instance.
Administration:-