Alternative strategy for storing (bi-directional) associations in MongoDB

Description

Currently we store the documents for both navigational directions of a bi-directional association in the same collection in MongoDB when using the COLLECTION_PER_ASSOCIATION strategy:

associations_AccountOwner_BankAccount

This requires to store the column name of the ids as we otherwise wouldn't know which side of the association a given record represents.

An alternative would be to use two separate collections for the both directions of the assocation, which allows for a more compact id syntax (assuming non-compound keys):

associations_AccountOwner_BankAccount

associations_BankAccount_AccountOwner

In a way that would closely resemble the IN_ENTITY strategy, only that the assocations are not stored as sub-documents within the entities but as separate documents. It should also be a bit more efficient as the key is not structured and only the half of documents needs to be searched when accessing one side of an association.

Environment

None

Assignee

Unassigned

Reporter

Gunnar Morling

Labels

None

Feedback Requested

None

Feedback Requested By

None

backPortable

None

Suitable for new contributors

None

Pull Request

None

backportDecision

None

backportReEvaluate

None

Components

Fix versions

Priority

Major
Configure