title: What is the right way of checking conditions in content providers?
body: <p>I have sqlite database and content provider which wraps it. There is the table of dictionaries and the table of words. Eeach word belongs to one of dictionaries. Also each dictionariy has constant capacity. So my content provider should allow to insert only limited amount of words in each dictionary.</p>
  
  <pre>
  "scheme"
  
  Dictionaries
  |-id (read-only)
  |-capacity
  
  Words
  |-id (read-only)
  |-dictionaryId (write-once)
  </pre>
  
  <p>I have a few options:</p>
  
  <p>1) For each new dictionary I can create trigger that will raise() error if amount of words is gather than capacity. But it will make query for each insertion that is redurant in some situations.</p>
  
  <p>2) I can check this condition in the provider's insert(). (same problem as above)</p>
  
  <p>3) I can pass this check to users of provider. For example check the condition in the activity which adds new words into dictionary. This is most optimized method because I don't need to make query each time I add new word. I can query the amount of words in the dictionary at the start of activity and then increment it and be aware of the relevant value without queries. But here I have another problem: what if i forget to check this condition or make mistake and condition won't work.</p>
  
  <p>So what is the right way of checking conditions in content providers?</p>