MongoDB Schema Design Best Practices

preview_player
Показать описание

Have you ever wondered, “How do I model my schema for my application?” It’s one of the most common questions devs have pertaining to MongoDB. And the answer is, it depends. This is because document databases have a rich vocabulary that is capable of expressing data relationships in more nuanced ways than SQL. There are many things to consider when picking a schema. Is your app read or write-heavy? What data is frequently accessed together? What are your performance considerations? How will your data set grow and scale?

In this video, Joe Karlsson will discuss the basics of data modeling using real-world examples. You will learn common methodologies and vocabulary you can use when designing your database schema on your application.

Chapters 📑
0:00 Intro
0:18 Why is schema design important?
1:21 Relational vs. MongoDB schema design
4:16 One to One
4:41 One to many
6:10 One to Squillions
8:02 Many to Many
8:57 Wrap Up

💬 What topics do you want to see covered next? Leave a comment below!

🔗 These ARE the links you are looking for 👋:

------
Рекомендации по теме
Комментарии
Автор

Rule 1: embed unless there is a compelling reason not to
Rule 2: avoid JOINS if they can be avoided
Rule 3: array should never grow without bound
Rule 4: an object should not be embedded if it needs to be accessed individually

chauphan
Автор

Not sure if i am fan of this delivery style but he was getting the point across.

paracha
Автор

Thanks Joe! That is gold. Very clear and so fun to watch!

elonhung
Автор

Coming from a SQL mindset to MongoDB is an interesting experience, but also kinda freeing in a way.. thanks for making this video!

jmanpolo
Автор

So, for many-to-many relationships, Joe suggests to store the relationship data in BOTH tables (very unlike SQL dbs where we avoid redundancy). This helped me resolve a quarrel with myself on the db schema for my first MongoDB Atlas Collections. Thanks Joe

picklebrownie
Автор

Good job explaining/confirming my loosely established notions about how to design a NoSQL database. Thanks Joe.

MongoDB is a low-resistance (easy to use) database that’s become my go-to data store for standing up products.

BobMacNeal
Автор

Things people really need to consider before moving everything to MongoDB. It isn't a relational database management system. Saying MongoDB is better than any RDBMS without first specifying the data shows a real lack of knowledge.

Key constraints don't exists in MongoDB. There are no referential integrity checks. We use MongoDB for blob storage and store the MongoDB keys in SQL Server. It's great for that but I would never outright replace a normalized SQL Server or a MySQL RDBMS instance with MongoDB.

Maybe a lot of people see MongoDB as being better because they don't want to worry about optimizing indexes and execution plans, and they see the "read" performance gains...but that comes at a cost of data integrity. It's a schemaless structure which means consistency doesn't exist. It will eat anything you feed it which can be dangerous.

Think about what happens over time as you add/remove properties from your JSON or add/remove reference data based on changing business rules. Think about what that conversion would look like in MongoDB compared to a RDBMS instance. Using the example in this video what if there was a business rule that allowed someone to remove a profession (physical or logical) from all users. Ask yourself what that would look like in MongoDB vs a Relational Database.

I know I sound pretty critical of MongoDB but I don't mean to. We use it and it works well for our needs but it's not a replacement for RDBMS. More of a supplement. NoSQL shines in write-once-read-many scenarios.

murph
Автор

Joe is kind of person that make learning fun

maxpayenvenic
Автор

MongoDB needs Joe, he's so good at explaining things <3

VoxyDev
Автор

I have never knew MondoDb schema design can be this entertaining. Thank you, Joe.

jbsinluenam
Автор

Omg. I really love about how Joe explain the all of these schema design. Never feel exciting like this when learning new concept. Thanks Joe ❤️.

laodemuhammadalfatih
Автор

Excellent video. This was my main concern when attempting a scheduler.

reallions
Автор

Great explanation. Just what I was looking for.

philyeo
Автор

Great tutorial, short and straight to the point

RN-ermz
Автор

i'm new on your VDO, Love it ! Great tutorial. you make learning super fun

niknacknutthapon
Автор

My app shows a profile page of a student with a list of classes she's enrolled in. Classic Student/Class/Enrolment tables in SQL. In Mongo I would want to just embed everything in 1 document. What if I change the name of a class, or a student drops a class previously enrolled? How do I do this WITHOUT joins? "Throw away" the document (delete) and just make a new one (like a piece of physical paper) with the updated stuff?

pazuso
Автор

I love the style of this video so much. It makes learning tech so much more fun compare to other monotone tech videos.

AnNguyen-pxlg
Автор

Explains the conept very well...thanks

oberoioffice
Автор

is joins in mongodb slower than sql server?
because if I use objectids, I will always need joins.

BelieveInPeople
Автор

Thank you . that's what i was looking for ;)

vaibhav