bidirectional relationships
As someone who's not experienced on the SQL side of things, would love to know if im missing anything and/or there's a better approach altogether.
The main features/capabilities for the friends feature will be to fetch a list of friends, as well as to update any meta data between these friends.
Fetching a users friends is much more frequent.
Bidirectional Approach:
Pros:
Only one document per friendship, which means writes are atomic and there is less data to keep in sync.
May be more intuitive from a data modeling perspective as a friendship is inherently a bidirectional relationship.
Cons:
More complex queries are required to find all friends of a given user.
The sorting mechanism for user IDs must be strictly followed on every operation to ensure data consistency.
Unidirectional Approach:
Pros:
Simpler and more efficient queries for fetching all friends of a user.
Cons:
Requires two documents for each friendship, doubling the write operations.
More complex logic needed to ensure both documents are kept in sync, despite transactions guaranteeing atomicity.
