title: How to make a column a primary and foreign key at the same time?
body: <p>I need to create a table with only one column that contains foreign keys. As <code>Room</code> forces me to also have a primary key, I want one column to be a primary and a foreign key at the same time. How can I do this? Further, does my primary/foreign key column has to be a <code>Long</code> or can it be <code>Item</code> and <code>Room</code> automatically picks it's primary key and stores it?</p>
  <pre><code>@Entity(tableName = &quot;items&quot;)
  data class Item (
      @PrimaryKey(autoGenerate = true)
      var itemId: Long = 0L, 
  
      var itemName: String = &quot;&quot;
  )
  
  @Entity(tableName = &quot;items_recent_searches&quot;)
  data class ItemRecentSearches (
  
      // how to make this also a foreign key to Item?
      // further, is it possible to make this as type Item instead of itemId
      // and room then makes the conversion for me?
      @PrimaryKey
      var itemId: Long
  )
  </code></pre>