Just wanted an opinion, or at least a rule of thumb over which is better in a database structure for CouchDB. Is it better to have all related data for an item in a single document, or have parts of all items in many documents?
Let me illustrate what I mean by giving you an example. I currently log 4 events from our system, at 1 minute intervals, lets call them event_1, event_2, event_3 and even_4. Data is stored for each of the 4 events, regardless of value (you'll always get a value, even if everything is okay).
Option 1: Group events, and append new timestamp/values to the document...
{
event_1: [
{ timestamp, value },
{ timestamp, value },
{ timestamp, value },
...etc
]
},
{
event_2: [
{ timestamp, value },
{ timestamp, value },
{ timestamp, value },
...etc
]
},
{
event_3: [
{ timestamp, value },
{ timestamp, value },
{ timestamp, value },
...etc
]
}
...etc
Option 2: Keep a huge list of documents, with the latest values (which is how they're actually delivered from the system)?
{
timestamp: {
{ event_1, value },
{ event_2, value },
{ event_3, value },
{ event_4, value }
}
},
{
timestamp: {
{ event_1, value },
{ event_2, value },
{ event_3, value },
{ event_4, value }
}
},
{
timestamp: {
{ event_1, value },
{ event_2, value },
{ event_3, value },
{ event_4, value }
}
}
...etc
I'm currently using the 2nd option, but was just curious to see peoples opinions on what would be considered best practice...I'm starting to think that Option 1 might be better, as the way i am reporting, results are grouped by event (shown in line graph of each event).