title: Room database: What is Index specific columns (indices and @Index) and how to use it?
body: <p>I was referring Index specific columns of Room Database.</p>
  
  <p>Below is some example code is written here <a href="https://developer.android.com/training/data-storage/room/defining-data#column-indexing" rel="noreferrer">https://developer.android.com/training/data-storage/room/defining-data#column-indexing</a> </p>
  
  <p><strong>Example Code-1:</strong></p>
  
  <pre><code>    @Entity(indices = {@Index("name"),
          @Index(value = {"last_name", "address"})})
  public class User {
      @PrimaryKey
      public int id;
  
      public String firstName;
      public String address;
  
      @ColumnInfo(name = "last_name")
      public String lastName;
  
      @Ignore
      Bitmap picture;
  }
  </code></pre>
  
  <p><strong>Example Code-2:</strong>  </p>
  
  <pre><code>@Entity(indices = {@Index(value = {"first_name", "last_name"},
          unique = true)})
  public class User {
      @PrimaryKey
      public int id;
  
      @ColumnInfo(name = "first_name")
      public String firstName;
  
      @ColumnInfo(name = "last_name")
      public String lastName;
  
      @Ignore
      Bitmap picture;
  }
  </code></pre>
  
  <p>This is described in room documentation by android,
     I have used indices for the uniqueness of column but what does above code means can anyone explain it? </p>
  
  <p>Q1: What is the use of indices and @Index?<br>
  Q2: What is the difference between <code>@Index("name")</code> and <code>@Index(value = {"last_name", "address"})</code>?</p>