title: how to insert data using room when we need foreign key in android kotlin?
body: <p>i have this kind of json data-&gt;</p>
  <pre><code>{
      &quot;author&quot;: &quot;Chinua Achebe&quot;,
      &quot;country&quot;: &quot;Nigeria&quot;,
      &quot;imageLink&quot;: &quot;images/things-fall-apart.jpg&quot;,
      &quot;language&quot;: &quot;English&quot;,
      &quot;link&quot;: &quot;https://en.wikipedia.org/wiki/Things_Fall_Apart\n&quot;,
      &quot;pages&quot;: 209,
      &quot;title&quot;: &quot;Things Fall Apart&quot;,
      &quot;year&quot;: 1958
    }
  </code></pre>
  <p>now  i have created two entities-&gt;</p>
  <p>Author.kt</p>
  <pre><code>@Entity(tableName = &quot;author_data&quot;)
  data class Author(
      @PrimaryKey(autoGenerate = true)
      val id: Int,
      val author_name: String,
      val country: String
  )
  </code></pre>
  <p>Book.kt</p>
  <pre><code>@Entity(tableName = &quot;book_data&quot;, indices = [Index(value = [&quot;title&quot;], unique = true)])
  data class Book(
      @PrimaryKey(autoGenerate = true)
      val id: Int,
      val title: String,
      val image_link: String,
      val language: String,
      val link: String,
      val age: Int,
      val year: Int
  )
  </code></pre>
  <p>now i want to add from json data to local storage but this is the thing-&gt;</p>
  <pre><code>Book must have int foreign key referencing Author entity.
  </code></pre>
  <p>how do i do that? someone help please. i am stuck.</p>
  <p>i am using kotlin.</p>
  <p>EDIT: above problem solved.</p>
  <p>Now what i want to know-&gt; is there any way to check if these tables already exist in local storage than i dont want to download the data again?</p>