开发者

Modelling datamodel for document database

开发者 https://www.devze.com 2023-01-29 11:45 出处:网络
I\'m starting out with Raven DB and am trying to wrap my head around the different document-model paradigm...

I'm starting out with Raven DB and am trying to wrap my head around the different document-model paradigm...

How would you structure the following, while being able to access a single event at a time, listing Albums, and inside that, listing Images.

Also I need to have a lightbox, storing single Images from different Albums.

+ Event
  + Album
    + Image
    + Image
  + Album

I tried to work out my root aggregates, but however I structure it, I wi开发者_开发知识库nd up with having Events, Albums and Images, all as top-level Elements because I need to address them separately. This however seems like a straight copy from a relational scheme, which isn't really useful.

How would you structure this?


I would store the images as attachments. That's assume there is no metadata that needs to be stored with images. Then, in each album I would simply store the urls to the images.

I'm not really sure what "event" means in this model. Does an album document have any meaning outside of event? If not, then I would just have an event document with the whole graph in it. I'm guessing that is not the case though, and that you want to access albums outside the context of events.

Next question, can an event be inferred from the document? If so, then I wouldn't model the event at all and just let it be defined as part of the index. Again, I'm guessing that's not the case.

If the two are really separate then there are two remaining choices that come to mind.

  1. Just duplicate the album data whenever an event is persisted. Especially if album data rarely changes.

  2. Store the albums as links, and use an include when retrieve them.

0

精彩评论

暂无评论...
验证码 换一张
取 消