I would like to have relationships:
- users
- accounts
- cards
- banks
- credit_processors.
The question is how to design the model in the db. I got into a confusion when these scenarios came across:
- A card can be issued by a bank and the bank would link the card to a credit processor for instance, Chase would use Visa on their cards, Bank of America would use Mastercard and Visa on their cards.
- A card can be issued by a credit processor WITHOUT a bank for instance, Visa can issue their own cards, American Express can issue their own cards.
When the relationships in the db would be like this:
an account belongs to a bank and can have a credit processor through the bank
an account belongs to a credit processor directly without a bank.
Here is the link to my db diagram. Is there a better way to design this db diagram?
Looks pretty good, but I don't think you need the 'resources' table since you can store the bank_id and the credit_processor_id in the 'cards' table
Just to walk through it from the top down
You may also want to do a many-to-many relationship between Banks and CreditProcessors depending on how often you think you'll query that.