Include primary key from other model or not in relationship

11 views
Skip to first unread message

Reza Shah

unread,
Jan 26, 2016, 6:12:29 PM1/26/16
to Realm Java
For example we have these models:

class People extends RealmObject {
    @PrimaryKey
     long peopleId;
     long dogId; //Should we include dogId or not? what is the best practice?
     Dog dog;
}

class Dog extends RealmObject {
    @PrimaryKey
     long dogId;
}

In my case People can only have one Dog. 
I have seen some people include 'dogId' explicitly while also having 'dog' as member of 'People' model.
And some are not.

What is the best practice for this relationship? Should we explicitly include primarkey from other model or not?

Thank you,
Reza

Reply all
Reply to author
Forward
0 new messages