title: How to decide which fields must be indexed in a database table
body: <h2>Explanation</h2>
  
  <p>I have a table which does not have a primary key (or not even a composite key).</p>
  
  <p>The table is for storing the time slots (opening hours and food delivery available hours) of the food shops. Let's call the table "business_hours" and the main fields are as below.</p>
  
  <ul>
  <li>shop_id</li>
  <li>day (0 - 6, means Sunday - Saturday)</li>
  <li>type (open, delivery)</li>
  <li>start_time</li>
  <li>end_time</li>
  </ul>
  
  <p>As an example, if shop A is opened on Monday from 9.00am - 01.00pm and 05.00pm to 10.00pm, there will be two records in business_hours table for this scenario.</p>
  
  <pre><code>-----------------------------------------------
  | shop_id | day | type | start_time | end_time
  -----------------------------------------------
  | 1000    | 1   | open | 09:00:00   | 13:00:00
  -----------------------------------------------
  | 1000    | 1   | open | 17:00:00   | 22:00:00
  -----------------------------------------------
  </code></pre>
  
  <p>When I query this table, I will use shop_id always as the first condition in where clause.</p>
  
  <p>Ex: </p>
  
  <pre><code>SELECT COUNT(*) FROM business_hours WHERE shop_id = 1000 AND day = 1 AND type = 'open' AND start_time &lt;= '13.29.00' AND end_time &gt; '13.29.00';
  </code></pre>
  
  <h2>Question</h2>
  
  <p>Applying index for "shop_id" is enough or "day" &amp; "type" fields also should be indexed?</p>
  
  <p>Also better if you can explain how the indexing really works.</p>