Hello Everyone!
I’m new to MongoDB, and I’m still trying to understand what is the best way to do things.
In particular, I have the following problem:
Let’s assume that I have a list of books and a list of movies organized like this:
A. Books
– i. Fantasy
---- 1. Lord of the Rings
---- 2. Shannara
– ii. Crime
---- 1. Sherlock Holmes
---- 2. Agatha Christie
B. Movies
– i. Sci-Fi
---- 1. Dune
---- 2. I, Robot
– ii. Historical
---- 1. Ben Hur
---- 2. Lawrence of Arabia
And then I have a series of Users, and Users can select one category of books or movies, and they can rate all of them. So for isntance:
Mark:
- A.i.1 = 5
- A.i.2 = 3
- B.ii.1 = 4
- B.ii.2 = 4
Lucy
- A.ii.1 = 1
- A.ii.2 = 4
- A.i.1 = 3
- A.i.2 = 5
- B.ii.1 = 5
- B.II.2 = 3
What is the best practice to store such data in a MongoDB database?
Should I create a collection with the basic lists, and a second collection with the users, and then i will just copy and embed the collection each used select into their specific document, and attach the score to such copy?
Or is there a way to keep the actual lists of items in the lists collection and keep the rankings in the Users documents and somehow link the two, but without coping and embedding the lists in the documents of each users selecting them?
I sorry if this sounds like a silly questions, but as said, i’m quite new…