Reputation: 10693
I'm new to the Mongodb approach to db design. I have users who can add Channels and Links where each Channel will potentially have many Links. Links will also be visited many times and therefore I need to store Visits too.
Specific links will need to be found at times as well as all links belonging to a specific channel. I would also need to be able to find all visits to a particular link regularly. Could someone tell me how they would design the db in this case?
I'm thinking of separate collections for each as I assume this would be more efficient for searching but I'm not entirely convinced this thinking is accurate.
Upvotes: 0
Views: 135
Reputation: 2064
take a look at the link James had provided. but aside from that, its all about the details. Its tempting to store links in the channels -- one collection. But, if you say each channel can have many links -- is that unbounded growth? if so, then you have to have separate collections where each channel references multiple links in another collection. Similar logic applies to Links and Visits (unless Visits is just a count?). You can also try to do a "hybrid" approach -- a channel will embed just a few links so they are retrieved "in one shot" with the channel, and the rest of the links are referenced
Upvotes: 1