文档数据库的数据模型建模

发布于 2024-10-07 00:32:35 字数 369 浏览 2 评论 0原文

我从 Raven DB 开始,并试图了解不同的文档模型范例...

您将如何构建以下内容,同时能够一次访问一个事件,列出专辑,以及其中的内容,列出图像。
我还需要一个灯箱,存储来自不同相册的单个图像。

+ Event
  + Album
    + Image
    + Image
  + Album

我试图计算出我的根聚合,但是无论我如何构建它,我最终都会将 EventsAlbumsImages 全部作为顶部-level 元素,因为我需要单独处理它们。然而,这似乎是关系方案的直接副本,这并不是真正有用。

你会如何构建这个?

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 wind 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷清清 2024-10-14 00:32:35

我会将图像存储为附件。这是假设没有需要与图像一起存储的元数据。然后,在每个相册中,我只需存储图像的 URL。

我不太确定“事件”在这个模型中意味着什么。专辑文档在活动之外还有任何意义吗?如果没有,那么我只会有一个包含整个图表的事件文档。
我猜情况并非如此,您希望在事件背景之外访问相册。

下一个问题,可以从文档中推断出事件吗?如果是这样,那么我根本不会对事件进行建模,而只是将其定义为索引的一部分。我再次猜测情况并非如此。

如果两者确实是分开的,那么我想到的还有两个选择。

  1. 每当事件持续存在时,只需复制专辑数据即可。特别是当专辑数据很少更改时。

  2. 将相册存储为链接,并在检索它们时使用包含。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文