Primary key of nested realm objects in Android
<p>I'm having a problem with Realm complaining about duplicate primary keys. Here's the issue:</p>

<p>I have two Realm Classes. I need to access both separately, and also, there is a many-to-one relationship from one to the other.</p>

<p>Topic:</p>

<pre><code>public class Topic extends RealmObject{

    @PrimaryKey
    private String id;

    private String subject;
    }
</code></pre>

<p>and Question:</p>

<pre><code>public class Question extends RealmObject {

    @PrimaryKey
    private String _id;
    private RealmList&lt;Option&gt; options = null;
    private RealmList&lt;Answer&gt; answer;
    private Topic topic;
}
</code></pre>

<p>More than one question can have the same topic. However, when I try to create the Realm Question DB, Realm throws the RealmPrimaryKeyConstraintException: Value already exists: exception. And the exception is thrown with a the primary key of the <strong>Topic</strong> class.</p>

<p>How can I avoid this? </p>