I’m currently building something using Mongo as the DB, and have so far been making sure to assign the user ID to everything that relates to that user when it’s created.
Wouldn’t you have to do something like that in MySQL anyway to ensure that the entries related to each other?
Oh yeah, I’m saying that relational databases push you even more to assign IDs to every miniscule piece of information, especially if you’re following best practices (3NF or similar).
For example, you’re not supposed to say that a user has a list of interests, you’re supposed to say that there’s users with a user_id and then there’s user_interests with a user_id and an interest_description, so two separate tables.
If those interests can be indexed, then you’d want three tables:
I mean, this might not be the best example, as it kind of makes sense to not always load the user interests whenever you do anything with the user, but yeah, the point is that you’re supposed to split it up into separate tables and then JOIN it as you need it.
With these RDBMS, your entire data loading logic is supposed to happen in-database, so you pretty much need to chop the data into the smallest possible parts and assign IDs to all of those parts, to give you the flexibility to access them how you need to.
Ahhh okay I see. I’ve developed sites for a decade but have never had to really consider how databases work in any great detail, which obviously now with mongo I am having to think about. Thank you for clarifying! I’ve got some reading to do 🫡
I’m currently building something using Mongo as the DB, and have so far been making sure to assign the user ID to everything that relates to that user when it’s created.
Wouldn’t you have to do something like that in MySQL anyway to ensure that the entries related to each other?
Oh yeah, I’m saying that relational databases push you even more to assign IDs to every miniscule piece of information, especially if you’re following best practices (3NF or similar).
For example, you’re not supposed to say that a user has a list of interests, you’re supposed to say that there’s
users
with auser_id
and then there’suser_interests
with auser_id
and aninterest_description
, so two separate tables.If those interests can be indexed, then you’d want three tables:
users(user_id)
interests(interest_id, description)
user_interests(user_id, interest_id)
(N-M-Mapping)I mean, this might not be the best example, as it kind of makes sense to not always load the user interests whenever you do anything with the user, but yeah, the point is that you’re supposed to split it up into separate tables and then JOIN it as you need it.
With these RDBMS, your entire data loading logic is supposed to happen in-database, so you pretty much need to chop the data into the smallest possible parts and assign IDs to all of those parts, to give you the flexibility to access them how you need to.
Ahhh okay I see. I’ve developed sites for a decade but have never had to really consider how databases work in any great detail, which obviously now with mongo I am having to think about. Thank you for clarifying! I’ve got some reading to do 🫡