user133316: When you check a transaction before adding it to a block what data source is used as a source to make sure all the coinbase transactions are valid.

user13866: A purely local database is generally used. The specifics are implementation dependent. It is for a software developer to choose. It may be sensible to use a popular DBMS for efficiency reasons but any system of storage and retrieval is sufficient.
The primary source of data used in validation is the replicated journal of all Bitcoin transactions since its beginning. This transaction journal is called the "blockchain". Every full-node (e.g. wallets like Bitcoin core) maintains its own copy of this transaction journal.
Spendable amounts of Bitcoin are kept track of in the form of unspent transaction outputs (UTXOs). Each transaction consumes one or more UTXOs as inputs and creates new UTXOs as outputs (including amounts of change being returned to the spender). Nodes generally maintain a list of the current set of UTXOs.
Coinbase transactions create new amounts for the block reward without consuming UTXOs. These amounts are constrained by the halving rules for block reward amounts. These rules are built into the software. Coinbase transactions also collect the transaction fees which are the difference between sum of inputs and sum of outputs for ordinary transactions in the block. So those amounts also don't need to be tracked back to specific UTXOs because the ordinary transactions will have already been validated against the UTXO set.

133316: <p>When you check a transaction before adding it to a block what data source is used as a source to make sure all the coinbase transactions are valid.</p>
 13866: <p>A purely local database is generally used. The specifics are implementation dependent. It is for a software developer to choose. It may be sensible to use a popular DBMS for efficiency reasons but any system of storage and retrieval is sufficient.</p>
<p>The primary source of data used in validation is the replicated journal of all Bitcoin transactions since its beginning. This transaction journal is called the &quot;blockchain&quot;. Every full-node (e.g. wallets like Bitcoin core) maintains its own copy of this transaction journal.</p>
<p>Spendable amounts of Bitcoin are kept track of in the form of unspent transaction outputs (UTXOs). Each transaction consumes one or more UTXOs as inputs and creates new UTXOs as outputs (including amounts of <a href="https://bitcoin.stackexchange.com/q/736/13866">change</a> being returned to the spender). Nodes generally maintain a list of the current set of UTXOs.</p>
<p>Coinbase transactions create new amounts for the block reward without consuming UTXOs. These amounts are constrained by the halving rules for block reward amounts. These rules are built into the software. Coinbase transactions also collect the transaction fees which are the difference between sum of inputs and sum of outputs for ordinary transactions in the block. So those amounts also don't need to be tracked back to specific UTXOs because the ordinary transactions will have already been validated against the UTXO set.</p>
