MongoDB - מסד נתונים מבוסס מסמכים
Airbnb משתמשת ב-MongoDB לחלק משמעותי מה-data שלה - בעיקר profile data ו-listing metadata. כל listing יכול להיות בית, דירה, סירה, או אוהל - עם attributes שונים לגמרי. SQL היה דורש עשרות tables ו-nullable columns לכל type. MongoDB פשוט מאפשר document שונה לכל listing.
Foursquare (ה-location app) בנה את כל ה-check-in data על MongoDB. 5 מיליון check-ins ביום, geo queries, ו-flexible venue data. MongoDB עם 2dsphere index על coordinates - queries של "venues near me" ב-milliseconds.
MongoDB אינו "SQL בלי schema" - הוא מודל data שונה לחלוטין עם tradeoffs שונים לחלוטין. צריך להבין את ה-tradeoffs לפני שבוחרים.
ה-rise של MongoDB בשנות ה-2010 נבע מhobby שהפך ל-trend: developers רצו לעבוד עם JSON, רצו להימנע מschema migrations, ורצו לdeploy מהר. MongoDB סיפקה את כל זה. אבל ב-scale, ה-"no schema" הפך ל-curse: collections עם documents ב-10 formats שונים (כי code שינה לאורך שנים), queries שלא יכולים לnormalize על inconsistent data, ו-bugs שכיוון ל-field שלא קיים מחזיר null בלי error.
ב-2018, MongoDB הוציאה version 4.0 עם multi-document ACID transactions. זה שינה את ה-value proposition: עכשיו אפשר לבנות על MongoDB גם use cases שדורשים transactions. אבל: transactions ב-MongoDB יקרות יחסית, ואם אתם צריכים הרבה transactions - כנראה PostgreSQL יהיה מהיר יותר ופשוט יותר. transactions ב-MongoDB מיועדות לedge cases, לא ל-primary use case.
ה-argument הנכון לטובת MongoDB בפרויקטים ספציפיים נוגע לflexibility אמיתית. product catalog שיש בו electronics (עם GPU, RAM, CPU) ו-clothing (עם sizes, colors, materials) ו-services (עם duration, certification) - אלה schemas שונים לחלוטין. ב-PostgreSQL, תוסיפו JSONB column לgabattributes. ב-MongoDB, documents שונים לגמרי. כשה-schema genuinely heterogeneous ו-access patterns הן "תן לי document מלא לפי ID" - MongoDB מסבבת. כשaccess patterns כוללות complex queries עם joins, aggregations, ו-consistency requirements - PostgreSQL עדיפה ב-majority של מקרים.
כשלבחור MongoDB ב-2025: כשה-primary access pattern הוא "תן לי document שלם לפי ID", כשה-schema genuinely שונה בין documents (product catalog עם electronics vs clothing vs services), וכשה-team כבר עובד עם Node.js ו-Mongoose. כשלא לבחור MongoDB: כשיש relationships מורכבים שדורשים JOINs, כשconsistency קריטית (financial data), וכשה-team מכיר SQL טוב. ה-"default to MongoDB" שהיה נפוץ ב-2012 כבר לא valid - PostgreSQL ב-2025 מטפלת ב-JSONB, flexible schemas, ו-document patterns בצורה טובה מספיק לרוב use cases.