Note that there are some explanatory texts on larger screens.

plurals
  1. POLarge document vs many documents
    text
    copied!<p>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?</p> <p>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).</p> <p><strong>Option 1:</strong> Group events, and append new timestamp/values to the document...</p> <pre><code>{ 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 </code></pre> <p><strong>Option 2:</strong> Keep a huge list of documents, with the latest values (which is how they're actually delivered from the system)?</p> <pre><code>{ 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 </code></pre> <p>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).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload