For those familiar with Room, is there a way to se...
# android
d
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
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
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
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
d
Ah thanks I figured it out!