Note that there are some explanatory texts on larger screens.

plurals
  1. PODocument design
    primarykey
    data
    text
    <p>I am trying out some different options to design and store a document structure in an efficient way in RavenDB.</p> <p>The structure I am handling user is Session and activity tracking information.</p> <p>A Session is started when a User logs into the system and the activities start getting created. There could be hundreds activities per session. The session ends when the user closes / logs out.</p> <p>A factor that complicates the scenario slightly is that the sessions are displayed in a web portal in real time. In other words: I need to keep track of the session and activities and correlate them to be able to find out if they are ongoing (and how long they have been running) or if they are done.</p> <p>You can also dig around in the history of course.</p> <p>I did some research and found two relevant questions here on stack overflow but none of them really helped me: <a href="https://stackoverflow.com/questions/6019288/document-structure-for-ravendb">Document structure for RavenDB</a> <a href="https://stackoverflow.com/questions/9042115/activity-stream-design-with-ravendb">Activity stream design with RavenDb</a></p> <p>The two options I have spiked successfully are: (simplified structures)</p> <p>1: </p> <pre><code>{ "User": "User1", "Machine": "machinename", "StartTime": "2012-02-13T13:11:52.0000000", "EndTime": "2012-02-13T13:13:54.0000000", "Activities": [ { "Text": "Loaded Function X", "StartTime": "2012-02-13T13:12:10.0000000", "EndTime": "2012-02-13T13:12:10.0000000" }, { "Text": "Executed action Z", "StartTime": "2012-02-13T13:12:10.0000000", "EndTime": "2012-02-13T13:12:10.0000000" } } </code></pre> <p>2:</p> <pre><code>{ "Session" : "SomeSessionId-1", "User": "User1", "Machine": "machinename", "Text": "Loaded Function X", "StartTime": "2012-02-13T13:12:10.0000000", "EndTime": "2012-02-13T13:12:10.0000000" } { "Session" : "SomeSessionId-1", "User": "User1", "Machine": "machinename", "Text": "Executed action Z", "StartTime": "2012-02-13T13:12:10.0000000", "EndTime": "2012-02-13T13:12:10.0000000" } </code></pre> <p>Alternative 1 feels more natural, comming from a relational background and it was really simple to load up a Session, add events and store away. The overhead of loading a Session object and the appending events every time feels really bad for insert performance.</p> <p>Alternative 2 feels much more efficient, I can simply append events (almost like event-sourcing). But the selections when digging around in events and showing them per session gets a bit more complex.</p> <p>Is there perhaps a third better alternative? Could the solution be to separate the events and create another read model? Am I overcomplicating the issue?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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