एचएमबी क्या है? MongoDB? Archiटेकचर, विशेषताएं और उदाहरण
⚡ स्मार्ट सारांश
MongoDB is a document-oriented NoSQL database used for high-volume data storage, using collections and documents instead of tables and rows. This resource explains MongoDB features, a document example, key architecture components, reasons to use it, data modelling, and how it differs from a relational database.

एचएमबी क्या है? MongoDB?
MongoDB एक दस्तावेज़-उन्मुख NoSQL डेटाबेस है जिसका उपयोग उच्च मात्रा में डेटा संग्रहण के लिए किया जाता है। पारंपरिक रिलेशनल डेटाबेस में तालिकाओं और पंक्तियों का उपयोग करने के बजाय, MongoDB संग्रह और दस्तावेज़ों का उपयोग करता है। दस्तावेज़ों में कुंजी-मूल्य जोड़े होते हैं जो डेटा की मूल इकाई हैं MongoDB. Collections contain sets of documents and functions, which is the equivalent of relational database tables. MongoDB यह एक डेटाबेस है जो 2000 के दशक के मध्य में प्रकाश में आया।
MongoDB विशेषताएं
- Each database contains collections which in turn contain documents. Each document can be different, with a varying number of fields. The size and content of each document can be different from each other.
- दस्तावेज़ संरचना डेवलपर्स द्वारा अपनी संबंधित प्रोग्रामिंग भाषाओं में अपने वर्गों और ऑब्जेक्ट्स का निर्माण करने के तरीके के अनुरूप है। डेवलपर्स अक्सर कहते हैं कि उनके वर्ग पंक्तियाँ और स्तंभ नहीं हैं, बल्कि कुंजी-मूल्य जोड़े के साथ एक स्पष्ट संरचना है।
- पंक्तियाँ (या दस्तावेज़ जैसा कि कहा जाता है MongoDB) do not need to have a schema defined beforehand. Instead, the fields can be created on the fly.
- डेटा मॉडल उपलब्ध है MongoDB allows you to represent hierarchical relationships, to store arrays, and to store other more complex structures more easily.
- अनुमापकता - MongoDB environments are very scalable. Companies across the world have defined clusters, with some of them running 100+ nodes with around millions of documents within the database.
MongoDB उदाहरण
नीचे दिया गया उदाहरण दिखाता है कि किसी दस्तावेज़ को किस प्रकार मॉडल किया जा सकता है MongoDB.
- _id फ़ील्ड किसके द्वारा जोड़ा जाता है MongoDB संग्रह में दस्तावेज़ को विशिष्ट रूप से पहचानने के लिए।
- What you can note is that the Order Data (OrderID, Product, and Quantity), which in RDBMS will normally be stored in a separate table, is actually stored as an embedded document in the collection itself in MongoDB. This is one of the key differences in how data is modeled in MongoDB.
के प्रमुख घटक MongoDB Archiटेक्चर
नीचे कुछ सामान्य शब्द दिए गए हैं जिनका प्रयोग MongoDB:
- _ id – यह प्रत्येक क्षेत्र में आवश्यक है MongoDB दस्तावेज़. _id फ़ील्ड दस्तावेज़ में एक अद्वितीय मान का प्रतिनिधित्व करता है. MongoDB दस्तावेज़। _id फ़ील्ड दस्तावेज़ की प्राथमिक कुंजी की तरह है। यदि आप _id फ़ील्ड के बिना कोई नया दस्तावेज़ बनाते हैं, MongoDB will automatically create the field. So for example, if we see the example of the above customer table, MongoDB will add a 24-digit unique identifier to each document in the collection.
| _पहचान | ग्राहक आईडी | ग्राहक का नाम | आदेश ID |
|---|---|---|---|
| 563479cc8a8a4246bd27d784 | 11 | Guru99 | 111 |
| 563479cc7a8a4246bd47d784 | 22 | ट्रेवर स्मिथ | 222 |
| 563479cc9a8a4246bd57d784 | 33 | निकोल | 333 |
- पुस्तक संग्रह – यह एक समूह हैping of MongoDB documents. A collection is the equivalent of a table which is created in any other RDBMS such as Oracle or MS SQL. A collection exists within a single database. As seen from the introduction, collections do not enforce any sort of structure.
- कर्सर - यह क्वेरी के परिणाम सेट के लिए एक पॉइंटर है। क्लाइंट परिणाम प्राप्त करने के लिए कर्सर के माध्यम से पुनरावृति कर सकते हैं।
- डाटाबेस – This is a container for collections, like in RDBMS wherein it is a container for tables. Each database gets its own set of files on the file system. A MongoDB सर्वर एकाधिक डाटाबेस संग्रहीत कर सकता है.
- दस्तावेज़ – एक रिकॉर्ड MongoDB collection is basically called a document. The document, in turn, will consist of field names and values.
- क्षेत्र – A name-value pair in a document. A document has zero or more fields. Fields are analogous to columns in relational databases. The following diagram shows an example of Fields with key-value pairs. So in the example below, CustomerID and 11 are one of the key-value pairs defined in the document.
- JSON – इसे इस नाम से जाना जाता है Javaलिपि ऑब्जेक्ट नोटेशन। यह संरचित डेटा को व्यक्त करने के लिए एक मानव-पठनीय, सादा पाठ प्रारूप है। JSON वर्तमान में कई प्रोग्रामिंग भाषाओं में समर्थित है।
_id फ़ील्ड और सामान्य संग्रह फ़ील्ड के बीच मुख्य अंतर पर बस एक त्वरित नोट। _id फ़ील्ड का उपयोग संग्रह में दस्तावेज़ों को विशिष्ट रूप से पहचानने के लिए किया जाता है और इसे स्वचालित रूप से जोड़ा जाता है MongoDB जब संग्रह बनाया जाता है.
क्यों का उपयोग करें MongoDB?
Below are a few of the reasons as to why one should start using MongoDB:
- दस्तावेज़ उन्मुख - जबसे MongoDB एक NoSQL टाइप डेटाबेस, रिलेशनल टाइप फॉर्मेट में डेटा रखने के बजाय, यह डेटा को दस्तावेजों में संग्रहीत करता है। यह बनाता है MongoDB very flexible and adaptable to real business world situations and requirements.
- तदर्थ प्रश्न - MongoDB फ़ील्ड, रेंज क्वेरीज़ और रेगुलर एक्सप्रेशन खोजों द्वारा खोज का समर्थन करता है। दस्तावेज़ों के भीतर विशिष्ट फ़ील्ड वापस करने के लिए क्वेरीज़ बनाई जा सकती हैं।
- सूचीकरण – Indexes can be created to improve the performance of searches within MongoDB. किसी भी क्षेत्र में MongoDB दस्तावेज़ को अनुक्रमित किया जा सकता है.
- प्रतिकृति - MongoDB can provide high availability with replica sets. A replica set consists of two or more MongoDB instances. Each replica set member may act in the role of the primary or secondary replica at any time. The primary replica is the main server which interacts with the client and performs all the read/write operations. The secondary replicas maintain a copy of the data of the primary using built-in replication. When a primary replica fails, the replica set automatically switches over to the secondary, and then it becomes the primary server.
- भार संतुलन - MongoDB डेटा को कई भागों में विभाजित करके क्षैतिज रूप से स्केल करने के लिए शार्डिंग की अवधारणा का उपयोग करता है MongoDB उदाहरणों। MongoDB यह एकाधिक सर्वरों पर चल सकता है, लोड को संतुलित कर सकता है और/या हार्डवेयर विफलता की स्थिति में सिस्टम को चालू रखने के लिए डेटा की प्रतिलिपि बना सकता है।
डेटा मॉडलिंग MongoDB
As we have seen from the introduction section, the data in MongoDB एक लचीली स्कीमा है। एसक्यूएल डेटाबेस, जहाँ डेटा डालने से पहले आपको तालिका की स्कीमा घोषित करनी होगी, MongoDBके संग्रह दस्तावेज़ संरचना को लागू नहीं करते हैं। इस तरह का लचीलापन ही इसे बनाता है MongoDB बहुत शक्तिशाली.
When modeling data in MongoDB, keep the following things in mind:
- What are the needs of the application – Look at the business needs of the application and see what data and the type of data are needed for the application. Based on this, ensure that the structure of the document is decided accordingly.
- What are the data retrieval patterns – If you foresee heavy query usage, then consider the use of indexes in your data model to improve the efficiency of queries.
- Are frequent inserts, updates, and removals happening in the database? Reconsider the use of indexes or incorporate sharding if required in your data modeling design to improve the efficiency of your overall MongoDB पर्यावरण.
के बीच अंतर MongoDB और आरडीबीएमएस
नीचे कुछ प्रमुख शब्द अंतर दिए गए हैं MongoDB and RDBMS:
| आरडीबीएमएस | MongoDB | अंतर |
|---|---|---|
| तालिका | पुस्तक संग्रह | In आरडीबीएमएस, the table contains the columns and rows which are used to store the data, whereas in MongoDB this same structure is known as a collection. The collection contains documents which in turn contain fields, which in turn are key-value pairs. |
| पंक्ति | दस्तावेज़ | RDBMS में, पंक्ति तालिका में एकल, अंतर्निहित संरचित डेटा आइटम का प्रतिनिधित्व करती है। MongoDBडेटा को दस्तावेज़ों में संग्रहीत किया जाता है। |
| स्तंभ | क्षेत्र | RDBMS में, कॉलम डेटा मानों के एक सेट को दर्शाता है। MongoDB are known as fields. |
| जुड़ती | एंबेडेड दस्तावेज़ | In RDBMS, data is sometimes spread across various tables, and in order to show a complete view of all data, a join is sometimes formed across tables to get the data. In MongoDB, the data is normally stored in a single collection, but separated by using embedded documents. So there is no concept of joins in MongoDB. |
Apart from the terms differences, a few other differences are shown below:
- रिलेशनल डेटाबेस डेटा अखंडता को लागू करने के लिए जाने जाते हैं। यह एक स्पष्ट आवश्यकता नहीं है MongoDB.
- RDBMS के लिए आवश्यक है कि डेटा सामान्यीकृत first so that it can prevent orphan records and duplicates. Normalizing data then has the requirement of more tables, which will then result in more table joins, thus requiring more keys and indexes. As databases start to grow, performance can start becoming an issue. Again, this is not an explicit requirement in MongoDB. MongoDB लचीला है और पहले डेटा को सामान्यीकृत करने की आवश्यकता नहीं है।


