Answer the question
In order to leave comments, you need to log in
Which storage scheme to choose?
There is an account entity, which contains several more entities inside. These entities simply describe the main entity in more detail. For example, the account contains a link to the profile, game progress, avatar, and more. Everything has a one-to-one relationship. That is, an account cannot have more than one profile, avatar, etc.
We decided to use postgres as the main database, and jsonb as the storage type.
Actually a question: how it is correct to store nested entities? In the form of separate fields, which will be the jsonb type? Or should each entity be placed in a separate table, which will be linked via a foreign key to the account entity?
In the first method, it is confusing that when changing the avatar, for example, you will have to save the entire account (unless spring-jpa knows how to update the entity according to the changed field). Yes, and in the code accountRepository will stick out everywhere, which is somewhat confusing.
In the second method, the presence of repeated foreign keys (one-to-one relationship, and the key itself in the form of uuid) and joins confuses.
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question