realm / realm-java

Realm is a mobile database: a replacement for SQLite & ORMs
http://realm.io
Apache License 2.0
11.45k stars 1.75k forks source link

multi table #7743

Closed dakexuan closed 1 year ago

dakexuan commented 1 year ago

Problem

how can i create double table base on one model?

Solution

No response

Alternatives

No response

How important is this improvement for you?

No response

rorbech commented 1 year ago

Hi @dakexuan. It is not clear what you mean by "double table". Could you elaborate a bit?

dakexuan commented 1 year ago

I have a model MessageEntity for storing group and individual chat messages,The message structure is the same,I'd like to store them separately,How can I do that?Like SQLit,a table can be created using different table names

clementetb commented 1 year ago

Hi @dakexuan you will need to create a second model with a copy of the data from the first.

If the use case is that a group or an individual owns a message, you might use object relationships to define it. It would allow reusing the same model whether an individual or a group binds it.

Realm even allows you to define backward relationships based on a relationship to be able to navigate the objects in any direction.

github-actions[bot] commented 1 year ago

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.