Sign in Go Pro

Storing Data in Android with Room

One to Many Relationships

This lesson is for PRO members.

Upgrade today to get access to all the PRO lessons.

Unlock this lesson

Up next




In this lesson, we'll describe what a one to many relationship is, and how we can use Room to model this relationship type.

We'll model our data so that one User can have multiple Tasks assigned to them. And we'll learn how to write a query which brings back an entity as well as all of its related entities.

Summary of Content:

  • What a one to many relationship is
  • Alternative ways of modelling users and tasks
  • Using an SQL JOIN query to obtain a task and its assigned user
  • Creating a wrapper class which contains both a Task and a User
  • @Embedded annotation
  • How to handle the scenario when multiple fields have a the same column name - Multiple fields have the same columnName
  • Adding a custom prefix using prefix property of @Embedded annotation





This course is not updated with the last syntax for query


Lessons in Storing Data in Android with Room