For those familiar with Room, is there a way to setup a 1-1 unidirectional relation? It seems every example I find assumed bidirectionality.
l
Luke Sleeman
12/05/2019, 5:18 AM
Its an interesting question! Are you sure its even possible?
Ultimately room is backed by a relational DB - how would you do a 1 - 1 unidirectional relationship at the table level?
d
David Whittaker
12/05/2019, 5:57 AM
So it's not quite 1-1. I have Photos and OptionSets. Each photo can be related to only one optionset. But more than one photo can point to the same optionset. But I don't need the OptionSets to know about which Photos they are related to.
b
bezrukov
12/05/2019, 6:28 AM
And what is a problem you faced with? Typically you need to add optionSetId column to Photos. Then you could declare PhotosWithOptionsSets via
@Relation
. At this point OptionsSet entity doesn't know about relation to Photos