title: How should I define different subsets of a common dataset in a web application?
body: <p>I am speccing out a potential project. The core of the project is a set of data that the client wants to be able to present to different third-parties. The client wants to be able to offer different subsets of the data to different third-parties.</p>
  
  <p>The data will be stored in a MySQL database. A web app will connect to the database and provide the data through an API to client applications. Each client application may have access to different records in the database. Here's some example data:</p>
  
  <pre><code>fruit
  id  name    color
  1   apple   red
  2   orange  orange
  3   grape   purple
  4   banana  yellow
  
  location
  id  name
  1   new york
  2   florida
  3   california
  
  fruit_location
  fruit_id   location_id
  1          1
  2          2
  3          3
  4          2
  </code></pre>
  
  <p>The API for this data would have methods like <code>get_all_fruit()</code> and <code>get_fruit_by_location()</code>.</p>
  
  <p>By default, client applications would have access to all of the data. However, a client may only want (or be allowed) access to information about fruit from Florida. Another application may need access to all data except for the grape record. Calls to the API methods would be the same for each application, but would return different data with some results possibly omitted, based on which client application is making the request.</p>
  
  <p>I am wondering what suggestions the amazing SO community members have for defining this sort of filter.</p>
  
  <ul>
  <li>Defined within the database </li>
  <li>Some type of configuration file</li>
  </ul>
  
  <p>The two primary concerns:</p>
  
  <ul>
  <li>Ease of creating and modifying the specified filter, these will be managed by an end user</li>
  <li>Performant for a low to moderate number of concurrent users</li>
  </ul>
  
  <p>Other notes</p>
  
  <ul>
  <li>The data will be read only for the client applications </li>
  <li>The data will change over time as new information is added or changed</li>
  </ul>
  
  <p>I know this is a bit general, let me know if I can provide any other specifics that would help. Thanks for taking the time to make suggestions!</p>