I have an ActiveRecord model named Transaction. 
Each transaction has four fields:
- TransactionID
 - Type of Transaction
 - UserID
 - Parent TransactionID
 
There are further two types of Transaction:
- Debit Transaction
 - Payback Transaction
 
For every Payback Transaction, the TransactionID of the Debit Transaction is mentioned in Parent TransactionID field.
Using ActiveRecord Query I have to find the unpaid Debit Transactions of a particular user ID.
Example data:
TransactionID Type of Transaction UserID Parent TransactionID
123           Debit               1      null
124           Debit               1      null
125           Credit              1      123
127           Debit               1      null
Querying the above data should return Transactions: 124, 127.