Bitcoin Core maintains the set of unconfirmed transactions it is aware of about within the mempool. The mempool knowledge construction tracks which UTXOs are consumed and created by these unconfirmed transactions. When a brand new transaction is available in, it’ll discover outputs both within the UTXO set, or within the pending outputs within the mempool.
Naturally, any transaction that will get included in a block should solely spend UTXOs that have been created earlier than it’s spending them. Thus, any mother or father transactions should seem within the block earlier than a corresponding baby transaction.