A transaction consumes inputs, and creates outputs (new 'unspent transaction outputs' or UTXOs). For the transaction to be valid, each input must be a valid UTXO that exists on the network. Full nodes keep a continually updated index of all valid UTXOs, that they can check against incoming transactions.