我正在努力实现以下目标:
我正在和100一起工作.
In code:个
@Entity(tableName = "BookReadingSchedule")
data class BookReadingSchedule(
@PrimaryKey
@ColumnInfo(name = "schedule_id")
val id: Long = 0,
val name: String = ""
)
@Entity(tableName = "Books")
data class Books(
@PrimaryKey
@ColumnInfo(name = "book_id")
val id: Long = 0,
val title: String = ""
)
@Entity(
tableName = "BooksToRead"
foreignKeys = [
ForeignKey(
entity = BookReadingSchedule::class,
parentColumns = ["BookReadingSchedule_id"],
childColumns = ["to_book_id"],
onDelete = ForeignKey.CASCADE,
onUpdate = ForeignKey.CASCADE
)
]
)
data class BooksToRead(
@PrimaryKey
@ColumnInfo(name = "id")
val id: Long = 0,
val title: String = ""
@ColumnInfo(name = "to_book_id", index = true)
val book_id: Long,
)
试图建立这种关系,但是,我不确定这是不是完全正确.我在微软上用过LINQ C#,但从来没有在Android上做过这么多.我在利用柯特林.
我选中的链接(before I posted here):
- Room DB three table relationship个
- Android Room: One database with multiple tables个
- How to join three tables in ROOM个
- Android room - 3 one-to-many relationship个
EDIT:,Idea is that for every schedule, there will be only a handful of books that were select to be included within that schedule..