Database design scenario for budget (whole and daily)
The easiest solution (probably) would be:

Have one table for the whole budget for each campaign (let users have more than one ad at a time :-):

CREATE TABLE budget
(
    campaign_id INTEGER PRIMARY KEY, 
    user_id INTEGER REFERENCES users(user_id),
    /* Assumption: your currency doesn't have decimals; or you're using cents
       as currency unit */
    original_budget    INTEGER NOT NULL,  
    available_budget   INTEGER NOT NULL,
    daily_budget_limit INTEGER NOT NULL,

    -- Security checks
    CHECK(original_budget &gt; 0),
    CHECK(original_budget &gt;= available_budget),
    CHECK(daily_budget_limit &gt; 0),
    CHECK(daily_budget_limit &lt;= original_budget)
) ;


Have a second table for the budget of just today

CREATE TABLE todays_budget
(
    campaign_id INTEGER NOT NULL REFERENCES budget(campaign_id) PRIMARY KEY,
    original_daily_budget INTEGER NOT NULL,
    available_daily_budget INTEGER NOT NULL,

    CHECK(available_daily_budget &gt;= 0)
) ;


Every day, at 00:00, perform the following operations:


Subtract the spent_budget (original_daily_budget - available_daily_budget) from the budget
DELETE everything from todays_budget
INSERT new rows to todays_budget, with both original_daily and available_daily budget equal to the min of (daily_budget_limit, available_budget)


This can be done with the following queries:


Subtract remaining from yesterday

UPDATE 
    budget
SET
    available_budget = available_budget - 
        (SELECT
            original_daily_budget - available_daily_budget
        FROM
            todays_budget tod
        WHERE
            tod.campaign_id = budget.campaign_id)
 WHERE
      campaign_id IN 
          (SELECT 
              campaign_id 
          FROM 
              todays_budget 
          WHERE 
               available_daily_budget &gt; 0
          ) ;

Clear out everything from todays_budget

DELETE
FROM todays_budget ;

And fill it up again

INSERT INTO todays_budget
   (campaign_id, original_daily_budget, available_daily_budget)
SELECT
    campaign_id, 
    CASE WHEN available_budget &gt; daily_budget_limit then
        daily_budget_limit
    ELSE
        available_budget
    END AS original_daily_budget,
    CASE WHEN available_budget &gt; daily_budget_limit then
        daily_budget_limit
    ELSE
        available_budget
    END AS available_daily_budget
FROM
    budget
WHERE
    available_budget &gt; 0 ;



And very time you show an ad: Subtract one from available_daily_budget

UPDATE 
    todays_budget
SET 
    available_daily_budget = available_daily_budget - 1
WHERE 
    campaign_id = ((the corresponding campaign_id)) ;




Notes


I'm using SQL to describe your scenario. It is possible to do the same with noSQL databses. I wouldn't. This works well under a relational model.
If using SQL, steps 1 through 3 should be wrapped in a transaction, under SET ISOLATION LEVEL SERIALIZABLE; to avoid concurrency issues. If any of the check constraints fails, the whole transaction will be aborted and you'll have to retry it as a whole.
I've tried to use SQL Standard as much as possible, specific databases could allow for (slightly) simpler queries.
I am ignoring very many details that should be taking into consideration in a realistic situation.