title: Database Schema knowledge boundaries
body: <p>I'm struggling to figure out where to put the knowledge about the database.</p>
  
  <p>For example:</p>
  
  <p>Lets say we have a database with operators of different enterprise and they operate in different states and different kinds of equipment. A operator can work in several states and for several companies for different kinds of equipment.</p>
  
  <p>So to model that my db model is like:</p>
  
  <pre>
  Operator table (dni, id)
  Company table (name, id)
  Equipment table (name, id)
  States table (name, id)
  </pre>
  
  <p>and the relation tables</p>
  
  <pre>
  OpComEq (idOp, idComp, idEq)
  OpComSt (idOp, idComp, idSt)
  </pre>
  
  <p>So if we want to retrieve an operator, we have to cross query.
  If a company tells us that a given operator no longer works with them, we have to delete all his links of this operator with this company had with states and with Equipments, and check if there is still any link with that operator (he might be working for another company etc) and if not, then delete him from the operator database.</p>
  
  <p>The problem I encounter is not knowing where to encapsulate this knowledge, inside the database class or inside the Operator class or maybe is another class.</p>
  
  <p>I know this is a concrete example but is an abstract problem I bet is already solved but i cant find the design pattern for this. Can you please help me with this? </p>