SQL बनाम NoSQL
SQL databases data को rows और columns की strict tables में रखते हैं, जबकि MongoDB जैसे NoSQL databases ज़्यादा flexible models इस्तेमाल करते हैं।
In this page:
SQL बनाम NoSQL
Relational databases को पहले से एक schema चाहिए, normalized tables के आर-पार joins इस्तेमाल करते हैं और SQL बोलते हैं। MongoDB related data को एक document में साथ रखता है, fields को vary होने देता है, और एक JSON query language इस्तेमाल करता है।
कोई भी generally बेहतर नहीं है: data shape, consistency needs, और team skills के आधार पर चुनें।
Note:
एक SQL row roughly एक MongoDB document है, और एक table roughly एक collection।
उदाहरण: SQL vs NoSQL
// SQL: SELECT name FROM users WHERE age > 30 ORDER BY name;
// Mongo: the same question as a query document
test> db.users.insertMany([{ _id: 1, name: "Cy", age: 41 }, { _id: 2, name: "Ada", age: 36 }, { _id: 3, name: "Bob", age: 25 }])
{ acknowledged: true, insertedIds: { '0': 1, '1': 2, '2': 3 } }
test> db.users.find({ age: { $gt: 30 } }, { name: 1, _id: 0 }).sort({ name: 1 })
[ { name: 'Ada' }, { name: 'Cy' } ]
⚠️ Run this in your own terminal or Node.js environment.
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the
view already swaps in the hi_ translation fields (or blanks these
out if untranslated), so this renders correctly for both languages
without a lang_code check here. #}
आम गलतियां
- यह मान लेना कि NoSQL का मतलब है कोई transactions नहीं
- यह मान लेना कि SQL scale नहीं कर सकता
- एक relational schema को बिना बदले MongoDB में copy करना
चैप्टर सारांश
- SQL tables, rows, और joins इस्तेमाल करता है
- MongoDB collections और documents इस्तेमाल करता है
- MongoDB documents shape में vary हो सकते हैं
- Data और access patterns के आधार पर चुनें
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: