The payment_type_id will let my app determine if it should refer to paypal_payments or stripe_payments table for payment details. The reference_id will be used to get the payment details from one of those tables.
I want to make reference_id a foreign key and have a constraint such that it will restrict updates and deletes on those payment ids. The database schema below shows my current setup without the FK on reference_id.
Is there a better way to design my table? Or is there a way for me to implment the FK with this current setup? I'd like to avoid having to have all the payment details within the payments table if I can seaprate it out appropriately based on payment type.