2

I have following entity "MyEntity" in my RavenDb

{
  Id: {Guid}
  //...
  //...
}

In the application there might occur a specific event relating to elements of MyEntity. Not I want to associate users (also in db of course) with this type of event in order to allow the eventhandler to handle the event only if there is a relation between MyEntity and User

Using MySQL I'd create a table which which aggregates MyEntity.Id with User.Id (and possibly a specific EventId) 1:x (x element N) so that I can query all items with a a specific Id (MyEntitiy.Id) and the corresponding User.Id

Is it okay to simply apply this approach to a document db like RavenDb? Or should I consider something else?

yBother
  • 648
  • 6
  • 25

1 Answers1

1

Relations between documents in RavenDB is implemented in the following way:

A document can reference any other document from the database by storing the referenced document ID in the document. Referenced documents are called: Related Documents.

For example, document employees/3-A is referring to document employees/2-A:

{
    "LastName": "Leverling",
    "FirstName": "Janet",
    "ReportsTo": "employees/2-A",
}

These related documents can be 'loaded', 'indexed' & 'queried on'.

Learn more about document Modeling & working with multiple documents in the following links:

Danielle
  • 3,324
  • 2
  • 18
  • 31