While these are both many-to-many relationships, the intersection table is bidirectional, while the sub-collection approach is only unidirectional. With intersection table, you can readily see which users have purchased a given course, but when all of the purchase data is stored in the user document itself, you have to traverse all of the users and aggregate that data manually...unless I'm missing something.
The intersection approach seems better and more reliable, as it avoids making the users and courses documents heavier with keys and refs. With intersection approach, querying the data from users -> courses or from courses -> users seem efficient and easy...A wonderful tutorial to watch on mongo associations... thank you!!!
Just to clarify, users, courses and purchase are not documents. They are collections. In sql if you call it a table, in mongo, its a collection. A document in mongo world would then be a single row from a sql table.
Windows users who are unable to copy can perform below steps to copy anything from your cmd.. Step1: Right Click on the task bar of your cmd and go to properties. Step2: Click and enable the ctrl+shift as copy command mentioned there then u can copy the selected area as ctrl+shift+c and paste as ctrl+shift+v
Sir Just a small note for every guy on windows cmd. In Command prompt/powershell to copy something just select the guy and tap with 2 fingers(for lappy) and where ever you want to paste it again 2 finger touch would surely do the trick
This approach is not applicable when a customer buys a product with multiple quantity. Or, a system may want to give the customer the customisation of a product (example: color, quantity, size etc.) In this case, a purchase table is required definitely. So, it's a good practice to use purchase table and, store purchase unique id in customer table to track the purchase or modify it later.
As Hitesh sir said in almost all videos of this Mongo DB series, it depends on the need of application. Since, we don't need colour, quantity, size in the scenario that Hitesh sir used in this video, so it was a perfect approach.
I would say the one knock i would say is that when you are creating a bridge table you should always use the tables that you are bridging. ie it should be called userCourses in the first example
Again, Thanks for the Video, but how can an user delete a single purchaseid, if he added in users collection? Is there any way ->users->purchaselist->purchaseid>delete, Sorry I am a beginner
To copy in windows CMD, just select text you want to copy and right click on it to copy the text. To paste text in CMD write your command and again right click where you want to paste the text. your text is pasted . so simple!!!
What to do if the size of the array increases the 16mb document limit of mongodb? I am using mongodb to store messages in chat rooms. I created chat rooms, messages collections. All the messages in all rooms will be stored as documents in messages collection, the object ids of messages are stored in an array field (similar to one in the video) in each room.
I think you can use SQL for this purpose. In your chat room the relation is always one (user) to many (messages) so you technically don't need mongodb. Just create two SQL tables one for users another for messages.
@@a.yashwanth Yes, you can do a standard relational approach in MDb but it doesn't perform well as compared to any RDBMS. I too have implemented a mixed approach in MDb and now my aggregation pipelines are too big 😂. It will not be a problem if the computer is good or number of simultaneous users are less.
is this way of nesting array of relational documents in both models performant?? seems incredibly wasteful but is it better, performance wise, than holding a classic many to many documents array?
Thank you for the video very helpful. I need help modelling a relationship where a single product is sold by multiple vendors on a multivendor site using MongoDB. For example you have different vendors having different prices for a specific iPhone.
Sir you said you'll discuss about why data in mongodb is not persistent when restarting it, I've checked in other videos but didn't find the solution for, how to save the data permanently in mongodb?
what is a user have purchased multiple courses, do we have to give the key names as purchaseID,..... , instead of that can't we simply create an object inside the user named purchases with keys course,course?, what is preferred the most here, Object or a List ?
Sir please roll out the update for the LCO app, we are unable to offline the videos and it take a lot time to load the videos and every one min or two mins the videos starts buffering it's really annoying sir, please roll out the update.
Think for a moment if a course is purchased by thousands of students then defiantly you will encounter large array document problem. Which may create performance problem. in my suggestions traditional relation database approach is better.
Hello sir, i want to buy HP envy, so i want to know that if that laptop is best for me asa programmer,i am computer science student!!! So please reply as soon as possible!
Hello Sir, I have this issue currently, I am in 12 Grade and in my free time, I learn these techs Adobe Illustrator, Python, Android Development at the same time. After doing them for 2 months, now I occasionally feel overwhelmed. I think, to continue with one or two techs and will learn the third one later, but there is fear that I will lose the knowledge that I have gained through 2 months which will result in my time being wasted. What's your opinion on this, Should I go with two or fewer techs or continue with three.
As much as you can, never settle. Human brain is easily able to memorize 1 standard book of 200 pages per DAY and is not even coming close to the limit. You will never overwhelm your brain capacity. Keep learning until you have time and power to do it
3:35 - He means one more collection (equivalent to a table in SQL).
Document is equivalent to a row in tables.
While these are both many-to-many relationships, the intersection table is bidirectional, while the sub-collection approach is only unidirectional. With intersection table, you can readily see which users have purchased a given course, but when all of the purchase data is stored in the user document itself, you have to traverse all of the users and aggregate that data manually...unless I'm missing something.
The intersection approach seems better and more reliable, as it avoids making the users and courses documents heavier with keys and refs. With intersection approach, querying the data from users -> courses or from courses -> users seem efficient and easy...A wonderful tutorial to watch on mongo associations... thank you!!!
Just to clarify,
users, courses and purchase are not documents. They are collections. In sql if you call it a table, in mongo, its a collection. A document in mongo world would then be a single row from a sql table.
Windows users who are unable to copy can perform below steps to copy anything from your cmd..
Step1: Right Click on the task bar of your cmd and go to properties.
Step2: Click and enable the ctrl+shift as copy command mentioned there
then u can copy the selected area as ctrl+shift+c and paste as ctrl+shift+v
You are the best best BEST teacher ever
Thank you Hitesh Sir👨💻❤️. I am working with 🔥firebase. And this mongo DB tutorial for (No SQL) relationships👫 are very useful for me
Sir Just a small note for every guy on windows cmd. In Command prompt/powershell to copy something just select the guy and tap with 2 fingers(for lappy) and where ever you want to paste it again 2 finger touch would surely do the trick
best development tutorial ..i am excited to buy node js course
MongoDb: Many-to-Many relationships so clearly defined. Thanks, Hitesh
{2022-12-23}
always help these video, and like a way to explaining every topic in a simple way
This series helping a lot to lean mongodb
Sir please work with big amount of data
This approach is not applicable when a customer buys a product with multiple quantity. Or, a system may want to give the customer the customisation of a product (example: color, quantity, size etc.)
In this case, a purchase table is required definitely.
So, it's a good practice to use purchase table and, store purchase unique id in customer table to track the purchase or modify it later.
As Hitesh sir said in almost all videos of this Mongo DB series, it depends on the need of application. Since, we don't need colour, quantity, size in the scenario that Hitesh sir used in this video, so it was a perfect approach.
Relationships are super helpful for bigger apps 🔥
For Windows Users You can do Copy Paste in Command Prompt. Just select the text and Press "Enter" it will get copied and then "RightClick" to Paste
I would say the one knock i would say is that when you are creating a bridge table you should always use the tables that you are bridging. ie it should be called userCourses in the first example
Man, i appreciate for your contribution to community :) this solution doesnt help too much, but thanks again :)
Do you have any other approach?
why don't we use the old approach, that is creating a third collection, as you mentioned? Are there any disadvantages?
But how to access both tables as join or something else at once.
awesome, thank you very much
Mongodb series is awesome. I absolutely loving it. plz make more videos on it
Excellent, thanks for the help full tutorial...
thanks for awesome way of explaining with beautiful smile...keep smiling
Thanks for amazing playlist on MongoDB
Again, Thanks for the Video, but how can an user delete a single purchaseid, if he added in users collection? Is there any way ->users->purchaselist->purchaseid>delete, Sorry I am a beginner
To copy in windows CMD, just select text you want to copy and right click on it to copy the text.
To paste text in CMD write your command and again right click where you want to paste the text. your text is pasted . so simple!!!
What to do if the size of the array increases the 16mb document limit of mongodb?
I am using mongodb to store messages in chat rooms.
I created chat rooms, messages collections. All the messages in all rooms will be stored as documents in messages collection, the object ids of messages are stored in an array field (similar to one in the video) in each room.
I think you can use SQL for this purpose. In your chat room the relation is always one (user) to many (messages) so you technically don't need mongodb. Just create two SQL tables one for users another for messages.
use cassandra
@@rishiktiwari I had followed this approach only in mongodb by creating 2 collections.
@@a.yashwanth Yes, you can do a standard relational approach in MDb but it doesn't perform well as compared to any RDBMS. I too have implemented a mixed approach in MDb and now my aggregation pipelines are too big 😂. It will not be a problem if the computer is good or number of simultaneous users are less.
@@rishiktiwari yeah. I too had aggregation pipelines around 5-8.
Great effort sir we will give the same effort in learning from the resources you provided 👏👏👏🙏
Super helpful. Thank you!
Sir please drop a video related to dbRefs everything related to that in mongodb that'll be very helpful
Windows users can use PowerShell instead.
very detailed tutorial, keep it up bro. thanks you so much god bless you
Love this series.
Very helpful
But is this solution scalable? How about the number of users for a particular goes in million? Will it not be difficult to maintain document
is this way of nesting array of relational documents in both models performant?? seems incredibly wasteful but is it better, performance wise, than holding a classic many to many documents array?
Thank you for the teaching Hitesh 👍 Waiting for the next lesson, and in the meantime jumping on your ReactJS course.
Thank you for the video very helpful. I need help modelling a relationship where a single product is sold by multiple vendors on a multivendor site using MongoDB. For example you have different vendors having different prices for a specific iPhone.
Sir you said you'll discuss about why data in mongodb is not persistent when restarting it, I've checked in other videos but didn't find the solution for, how to save the data permanently in mongodb?
Thanks! great guide to mongo!
Sir plz continue this series...plz plz
Hi Hitesh, Regarding Relation in mongodb can you share more videos .no much clarity on Relations
Suppose we have multiple courses, so what to do if we want to calculate price of the courses in purchase table???
good course
awsome series keep going sir!!!!
Hi Sir,
Please continue this series with more levels. I am really enjoying it.
what is a user have purchased multiple courses, do we have to give the key names as purchaseID,..... ,
instead of that can't we simply create an object inside the user named purchases with keys course,course?,
what is preferred the most here, Object or a List ?
Sir please roll out the update for the LCO app,
we are unable to offline the videos and it take a lot time to load the videos and every one min or two mins the videos starts buffering it's really annoying sir, please roll out the update.
It’s definitely your internet or a device, I have no problems on my iPhone and iPad.
hey thanx man, you really help a lot.
Thanks sir for this series
Hello Sir,
Can you please share that, where you learn about programming, coding, technology, and this kind of technique?
Is there a way to append new "course_id" to existing courselist without removing the previous list of courses in courselist ?
I always use intersection tables as a rule.
Thanks for videos
How to get the list of documents in a database?
Thanks sir.... Appreciate your efforts
Think for a moment if a course is purchased by thousands of students then defiantly you will encounter large array document problem. Which may create performance problem. in my suggestions traditional relation database approach is better.
An amazing series thanks for the efforts sir :)
Thanks 😃
anyone did that assignment??
Hello sir, i want to buy HP envy, so i want to know that if that laptop is best for me asa programmer,i am computer science student!!!
So please reply as soon as possible!
Watch this video if u are confused about which laptop to buy th-cam.com/video/DAek73JBUQs/w-d-xo.html
many to many relation data how to update?
thank you
thank for video
I think you are confusing collections with documents. Anyway good tutorials.
surprised that only few have recognized that so far.
@@blasttrash Yes I think that too.
Thanks for teaching us this amazing MongoDB course with so much enthusiasm
Hello Sir, I have this issue currently, I am in 12 Grade and in my free time, I learn these techs Adobe Illustrator, Python, Android Development at the same time. After doing them for 2 months, now I occasionally feel overwhelmed. I think, to continue with one or two techs and will learn the third one later, but there is fear that I will lose the knowledge that I have gained through 2 months which will result in my time being wasted. What's your opinion on this, Should I go with two or fewer techs or continue with three.
As much as you can, never settle. Human brain is easily able to memorize 1 standard book of 200 pages per DAY and is not even coming close to the limit. You will never overwhelm your brain capacity. Keep learning until you have time and power to do it
Thanks man
thanks
Sir how many days will it take to learn JavaScript??
10-15 days are enough for basics then... Make project based on js and eventually u will learn it. Checkout my channel for amazing JavaScript content
Sir I need your help. Are you free
Windows User can copy the text from CMD,,,,,select the text and press CTRL+C or ENTER. It will not kill the terminal,,,RIGHT_CLICK to paste.
😇
First View and Comment
I am second...!!!
Thank you
thanks