Many to Many relation in mongoDB

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ก.พ. 2025

ความคิดเห็น • 103

  • @rishiktiwari
    @rishiktiwari 4 ปีที่แล้ว +11

    3:35 - He means one more collection (equivalent to a table in SQL).
    Document is equivalent to a row in tables.

  • @collink7145
    @collink7145 4 ปีที่แล้ว +8

    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.

  • @MrAnupkash
    @MrAnupkash 4 ปีที่แล้ว +2

    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!!!

  • @blasttrash
    @blasttrash 5 ปีที่แล้ว +2

    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.

  • @kushagraankit1578
    @kushagraankit1578 4 ปีที่แล้ว +1

    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

  • @pjguitar15
    @pjguitar15 4 ปีที่แล้ว

    You are the best best BEST teacher ever

  • @tejasjani2544
    @tejasjani2544 4 ปีที่แล้ว +1

    Thank you Hitesh Sir👨‍💻❤️. I am working with 🔥firebase. And this mongo DB tutorial for (No SQL) relationships👫 are very useful for me

  • @sobhitdas3071
    @sobhitdas3071 4 ปีที่แล้ว +1

    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

  • @seniorx9173
    @seniorx9173 3 ปีที่แล้ว

    best development tutorial ..i am excited to buy node js course

  • @Pareshbpatel
    @Pareshbpatel 2 ปีที่แล้ว

    MongoDb: Many-to-Many relationships so clearly defined. Thanks, Hitesh
    {2022-12-23}

  • @tejassarvaiya5589
    @tejassarvaiya5589 2 ปีที่แล้ว

    always help these video, and like a way to explaining every topic in a simple way

  • @shalakamhetre8093
    @shalakamhetre8093 4 ปีที่แล้ว

    This series helping a lot to lean mongodb

  • @anshikgupta2993
    @anshikgupta2993 5 ปีที่แล้ว +13

    Sir please work with big amount of data

  • @mubin986
    @mubin986 5 ปีที่แล้ว +3

    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.

    • @farhan787
      @farhan787 5 ปีที่แล้ว

      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.

  • @HostDotPromo
    @HostDotPromo 5 ปีที่แล้ว +2

    Relationships are super helpful for bigger apps 🔥

  • @ziaulhaqp5769
    @ziaulhaqp5769 4 ปีที่แล้ว

    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

  • @Gbyrd99
    @Gbyrd99 4 ปีที่แล้ว

    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

  • @rufatzeynalli5538
    @rufatzeynalli5538 5 ปีที่แล้ว +1

    Man, i appreciate for your contribution to community :) this solution doesnt help too much, but thanks again :)

    • @a.yashwanth
      @a.yashwanth 4 ปีที่แล้ว

      Do you have any other approach?

  • @firstnamelastname4685
    @firstnamelastname4685 4 ปีที่แล้ว +2

    why don't we use the old approach, that is creating a third collection, as you mentioned? Are there any disadvantages?

  • @muditmohantyagi
    @muditmohantyagi 3 ปีที่แล้ว

    But how to access both tables as join or something else at once.

  • @davidobodo3605
    @davidobodo3605 ปีที่แล้ว

    awesome, thank you very much

  • @pratiksukhe8560
    @pratiksukhe8560 5 ปีที่แล้ว

    Mongodb series is awesome. I absolutely loving it. plz make more videos on it

  • @remoteqa6311
    @remoteqa6311 4 ปีที่แล้ว

    Excellent, thanks for the help full tutorial...

  • @sklearn9391
    @sklearn9391 4 ปีที่แล้ว

    thanks for awesome way of explaining with beautiful smile...keep smiling

  • @yashpalgandhi4108
    @yashpalgandhi4108 3 ปีที่แล้ว

    Thanks for amazing playlist on MongoDB

  • @aninditadas7348
    @aninditadas7348 4 ปีที่แล้ว

    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

  • @axaysushir
    @axaysushir 4 ปีที่แล้ว

    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!!!

  • @a.yashwanth
    @a.yashwanth 4 ปีที่แล้ว +1

    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.

    • @rishiktiwari
      @rishiktiwari 4 ปีที่แล้ว

      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.

    • @kumarshubham4392
      @kumarshubham4392 3 ปีที่แล้ว

      use cassandra

    • @a.yashwanth
      @a.yashwanth 3 ปีที่แล้ว

      @@rishiktiwari I had followed this approach only in mongodb by creating 2 collections.

    • @rishiktiwari
      @rishiktiwari 3 ปีที่แล้ว +1

      @@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.

    • @a.yashwanth
      @a.yashwanth 3 ปีที่แล้ว +1

      @@rishiktiwari yeah. I too had aggregation pipelines around 5-8.

  • @Atulchourasia01
    @Atulchourasia01 4 ปีที่แล้ว

    Great effort sir we will give the same effort in learning from the resources you provided 👏👏👏🙏

  • @TomSkylark
    @TomSkylark 4 ปีที่แล้ว

    Super helpful. Thank you!

  • @anshikgupta2993
    @anshikgupta2993 5 ปีที่แล้ว +2

    Sir please drop a video related to dbRefs everything related to that in mongodb that'll be very helpful

  • @sriramtorvi7417
    @sriramtorvi7417 5 ปีที่แล้ว

    Windows users can use PowerShell instead.

  • @anonysmooth648
    @anonysmooth648 5 ปีที่แล้ว

    very detailed tutorial, keep it up bro. thanks you so much god bless you

  • @rajeshdonepudi1
    @rajeshdonepudi1 5 ปีที่แล้ว

    Love this series.

  • @rokibDev
    @rokibDev 2 ปีที่แล้ว

    Very helpful

  • @shashanksinha6966
    @shashanksinha6966 4 ปีที่แล้ว

    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

  • @silberJon
    @silberJon 5 ปีที่แล้ว

    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?

  • @alexnedin
    @alexnedin 5 ปีที่แล้ว

    Thank you for the teaching Hitesh 👍 Waiting for the next lesson, and in the meantime jumping on your ReactJS course.

  • @ozgenx7249
    @ozgenx7249 4 ปีที่แล้ว

    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.

  • @charannara3050
    @charannara3050 4 ปีที่แล้ว

    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?

  • @wehavebeenthere126
    @wehavebeenthere126 4 ปีที่แล้ว

    Thanks! great guide to mongo!

  • @sujanb3932
    @sujanb3932 5 ปีที่แล้ว

    Sir plz continue this series...plz plz

  • @Arun-wi9ir
    @Arun-wi9ir 5 ปีที่แล้ว

    Hi Hitesh, Regarding Relation in mongodb can you share more videos .no much clarity on Relations

  • @harshilbulsara4053
    @harshilbulsara4053 4 ปีที่แล้ว

    Suppose we have multiple courses, so what to do if we want to calculate price of the courses in purchase table???

  • @keniljoshi6092
    @keniljoshi6092 3 ปีที่แล้ว

    good course

  • @rachitmahajan7868
    @rachitmahajan7868 5 ปีที่แล้ว

    awsome series keep going sir!!!!

  • @aishadeshmukh6907
    @aishadeshmukh6907 5 ปีที่แล้ว +1

    Hi Sir,
    Please continue this series with more levels. I am really enjoying it.

  • @MohitSingh-po1rw
    @MohitSingh-po1rw 5 ปีที่แล้ว

    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 ?

  • @mujtabam265
    @mujtabam265 5 ปีที่แล้ว +1

    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.

    • @alexnedin
      @alexnedin 5 ปีที่แล้ว

      It’s definitely your internet or a device, I have no problems on my iPhone and iPad.

  • @abhishekkapoor692
    @abhishekkapoor692 5 ปีที่แล้ว

    hey thanx man, you really help a lot.

  • @ProgrammingWithProject
    @ProgrammingWithProject 5 ปีที่แล้ว

    Thanks sir for this series

  • @manishverma9987
    @manishverma9987 5 ปีที่แล้ว

    Hello Sir,
    Can you please share that, where you learn about programming, coding, technology, and this kind of technique?

  • @phani_kiran
    @phani_kiran 5 ปีที่แล้ว

    Is there a way to append new "course_id" to existing courselist without removing the previous list of courses in courselist ?

  • @rikyriky966
    @rikyriky966 5 ปีที่แล้ว +1

    I always use intersection tables as a rule.

  • @biswajeetpadhi5713
    @biswajeetpadhi5713 4 ปีที่แล้ว

    Thanks for videos

  • @akshitagarg5914
    @akshitagarg5914 5 ปีที่แล้ว

    How to get the list of documents in a database?

  • @nikhil.pandey
    @nikhil.pandey 5 ปีที่แล้ว

    Thanks sir.... Appreciate your efforts

  • @muhammadomer2259
    @muhammadomer2259 7 หลายเดือนก่อน

    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.

  • @kakhan2086
    @kakhan2086 5 ปีที่แล้ว

    An amazing series thanks for the efforts sir :)

  • @supunbandara1768
    @supunbandara1768 4 ปีที่แล้ว

    anyone did that assignment??

  • @VivekPatel-jm7vr
    @VivekPatel-jm7vr 5 ปีที่แล้ว

    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!

    • @CODERSNEVERQUIT
      @CODERSNEVERQUIT 5 ปีที่แล้ว +1

      Watch this video if u are confused about which laptop to buy th-cam.com/video/DAek73JBUQs/w-d-xo.html

  • @tapashalder8039
    @tapashalder8039 4 ปีที่แล้ว

    many to many relation data how to update?

  • @SamareshMaity231
    @SamareshMaity231 4 ปีที่แล้ว

    thank you

  • @be_29_salim_samim_khansali10
    @be_29_salim_samim_khansali10 5 ปีที่แล้ว

    thank for video

  • @ajay316
    @ajay316 5 ปีที่แล้ว +3

    I think you are confusing collections with documents. Anyway good tutorials.

    • @blasttrash
      @blasttrash 5 ปีที่แล้ว

      surprised that only few have recognized that so far.

    • @subhamray1203
      @subhamray1203 4 ปีที่แล้ว

      @@blasttrash Yes I think that too.

  • @abhisheksinghbhadauriya
    @abhisheksinghbhadauriya 5 ปีที่แล้ว

    Thanks for teaching us this amazing MongoDB course with so much enthusiasm

  • @GurdeepSingh-gr7fb
    @GurdeepSingh-gr7fb 5 ปีที่แล้ว

    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.

    • @meyimagalot9497
      @meyimagalot9497 5 ปีที่แล้ว

      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

  • @shbita
    @shbita 5 ปีที่แล้ว

    Thanks man

  • @awesomeclicks722
    @awesomeclicks722 5 ปีที่แล้ว

    thanks

  • @princeraj622
    @princeraj622 5 ปีที่แล้ว

    Sir how many days will it take to learn JavaScript??

    • @CODERSNEVERQUIT
      @CODERSNEVERQUIT 5 ปีที่แล้ว

      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

  • @theeagle8180
    @theeagle8180 5 ปีที่แล้ว +1

    Sir I need your help. Are you free

  • @iabhishekpatil4415
    @iabhishekpatil4415 4 ปีที่แล้ว

    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.

  • @barked2786
    @barked2786 ปีที่แล้ว

    😇

  • @anshulgupta3795
    @anshulgupta3795 5 ปีที่แล้ว

    First View and Comment

  • @mujtabam265
    @mujtabam265 5 ปีที่แล้ว

    I am second...!!!

  • @arjunshivhare8998
    @arjunshivhare8998 2 ปีที่แล้ว

    Thank you

  • @Avinashkumar-xt4zq
    @Avinashkumar-xt4zq 3 ปีที่แล้ว

    thanks