Dealing with duplication in RavenDB

57 views Asked by At

Taking my first shot at NoSQL development using RavenDB.

One thing that is confusing me is how we should handle duplicates across documents that are stored.

Let's say I have a Story (think BDD/ATDD):

{ 
    Id: 10,
    Title: 'Story 1'
}

Then I decide that a story can have one or more sub-stories. I then create another story and make then above story a sub-story.

{
    Id: 15,
    Title: 'Title',
    Stories: [ { Id: 10, Title: 'Story 1' }]
}

Now I've got two stories. If I load the story with ID=15 and proceed to edit the first story in the Stories array, let's say, with a new title of 'Sub-story 1', the original story stays the same.

What I'm trying to understand: Do I care? If I do, what is the best way to make sure that everything stays in sync? When the sub-story is changed, I want the original story to change as well. What is the appropriate design/solution for this kind of thing?

1

There are 1 answers

1
Ayende Rahien On

The quick answer is that you shouldn't model things like that. See: http://ayende.com/blog/156353/entities-associations-point-in-time-vs-current-associations