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.
2 Answers
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.
In order to be able to tell whether an unconfirmed transaction is eligible for block inclusion, a node checks that the UTXO spent in the transaction's inputs are available for spending and that the transaction is well-formed according to the protocol rules. To that end, the node must enforce all protocol rules, be caught up to the chain tip, and know the complete UTXO set.
Coinbase transactions have slightly different rules in that they don't have inputs but their outputs are constrained by the block subsidy schedule and the transaction fees of the remaining transactions in their corresponding block. To assess the validity of coinbase transactions, the node must have checked all transactions in the block, tallied the transaction fees, and then verify the amounts in the coinbase and (for segwit blocks) the presence of the correct witness commitment in an OP_RETURN output. Since transactions do not explicitly state the input amounts or the transaction fees, the UTXO values must be known beforehand to calculate the transaction fees. The blockchain therefore has to be processed in full and in order.