title: The best way to store the following temporal data in DB
body: <p>Imagine we have a set of entities each of which has its state: free, busy or broken. The state is specified for a day, for example, today on 2011-05-17 an entity E1 is free and tomorrow on 2011-05-18 it is busy.</p>
  
  <p>There is a need to store ~10^5 entities for 1000 days. Which is the best way to do so?</p>
  
  <p>I am thinking about 2 options:</p>
  
  <ul>
  <li>represent each day as a character "0", "1" or "2" and store for every entity a string of 1000 characters</li>
  <li>store each day with entity's state in a row, i.e. 1000 rows for an entity</li>
  </ul>
  
  <p>The most important query for such data is: given start date and end date identify which entities are free.</p>
  
  <p>Performance is of higher priority than storage.</p>
  
  <p>All suggestions and comments are welcome.</p>