According the entity-relationship model, the relationship between tbl_post
and tbl_category
could be specified using Room Persistency Library as follows:
@Entity(foreignKeys = @ForeignKey(
entity = TblPost.class,
parentColumns = "id",
childColumns = "tbl_post_id")
)
class TblPostCategory {
@PrimaryKey
public String id;
@ColumnInfo(name = "user_id")
public String postId;
}
However TblPostCategory
depends on two foreign keys: post_id
and category_id
from TblPost
and TbCategory
.
How the relationship should be described using Room annotations?
TblCategory.java
TblPost.java (It is missing the foreign key reference but it is not important for the case)
TblPostCategory.java