thanks a lot !
If I am reading it correctly, you are looking for Experience Targeting where Experience Audiences are derived by a value that you are extratcing from your dataabse. In that case, flow will look like:
1. Data (for your example, this will be ID 0 or 1) on the basis of which experience needs to be selected.
2. Pass this data using targetPageParams to Global mbox call (say expId=0 and expId=1)
3. Create Audiences on the basis of passed parameter and different values.
4. Use these audiences in an Experience Targeting activity where offer-code just returns a JSON object as you have stated below.
Let me know if my interpretation was wrong,