As part of my database I have 2 tables (clients and loans), of which I am interested in operating with the following fields:
- LOANS: (Customer ID, Loan Amount)
- CLIENTS: (Customer ID)
Consider that a client can have several loans.
What I should do, is to generate a view that shows all the clients (their personal information) and at the end of the registration the sum of the amounts of their loans. Let me explain with an example ...
If in USERS I have Juan with id = 1 and in LOANS I have registered that the client with id = 1 requested 3 loans of $ 100, $ 200 and $ 300, I must show the following record:
ID: 1 - Name: Juan - (Other information fields) - Debt: $ 600
And so for all customers , if a customer has not asked for loans, I show their registration with a "$ 0" at the end.
I have the restriction that I should not create the Debt field in the CLIENTS table (which I understand because it would generate redundancy).
My problem is that I do not know how to assign the sum of LOAN amounts to its respective user in CLIENTS
Can someone help me with the consultation?