I am currently thinking about how to structure data for a node.js app i will be developping.
I am thinking of using Mongo as database, but cannot think of a good way to accomplish what I want. All my researches led me to cross-documents references, but this is not what i am looking for, as everything lies in my 'event' document.
My document consists in an event in which people take part that can be represented like that :
{
name: "Some event name",
people: ["A", "B", "C", "D", ... ], // Could be more complex objects, with name, mail for instance
actions : [
{
name: "Some action name"
someAttr: 4.21
leader: "A" // One of people
followers : ["A", "B", "D"] // from people too
},
...
]
}
As you can see, the people are repeated in the document. They can be repeated numerous times as each event will gather lots of actions.
Should I keep my schema this way, or is there something more clever to do such as referencing people from the actions with the index of the global people list with something like that ?
{
name: "Some event name",
people: ["A", "B", "C", "D", ... ],
actions : [
{
name: "Some action name"
someAttr: 4.21
leader: 0
followers : [0, 1, 3]
},
...
]
}
If so, what is the smartest way to accomplish that ?
Thank you very much
Note : This is a theoretical question, and I am a beginner in the Mongo and node.js world