title: SQLite: implementing reference counter in partitioned tables
body: <p>I have 2 series of tables.</p>
  
  <p>In series A each table is defined as (id_a TEXT PRIMARY KEY NOT NULL, id_b TEXT NOT NULL);</p>
  
  <p>In series B each table defined as (id_b TEXT NOT NULL, value_b INT);</p>
  
  <p>It is implied that series A bigger than series B (may contain more tables).</p>
  
  <p>Also in series A the field id_b of each table may hold the value of some field id_b in series B only. </p>
  
  <p>I want value_b in series B to be a reference counter - whenever in series A added/deleted row with some id_b, the value of value_b in series B will increase/decrease for corresponding id_b by number of affected rows.</p>
  
  <p>How can it be implemented while keeping minimum diskspace/time consumption?</p>