Click here to Skip to main content
14,539,164 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have a few questions to ask. I already have a table that serves as sign up and login for users; it has email, username and password. Will I have to add three columns like credit_amount, debit_amount and balance_amount (AS INTEGERS DATA TYPE) to the table, that will serve as

credit for deposits (that is positive +)
debit for any service used (that is negative -)
balance for the sum total left
And if so, will there be a way to make the already existing table accept data into fields like email, username and password, with other new fields like credit_amount, debit_amount and balance_amount being empty ? I dont know how to interface with a payemtn gateway and also coding for credit, debit and sum query. Please kindly help. thank you.

What I have tried:

I have not tried anything yet but I am hoping to get some directions towards this before starting my coding
Posted
Updated 2 days ago
Rate this:
Please Sign up or sign in to vote.

Solution 1

The normal way to do this would be to use a separate table for these, utilizing a Foreign Key relationship with the Account Table.
This would give a 1:many relationship between the account and all of the transactions they did.
The advantage of this is that you would have a running total of all of the transactions that the account holder does; and could bring back their given balance for any given time.
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

I'll one-up MadMyche and say I'd add two new tables. One to hold user's current balance details, and one to hold all of their historic transactions. You should keep your existing login table holding nothing but login information, and create a balance table to hold things like current balance, and a transactions table to track the details of individual trnasactions. These will all be linked by foreign keys, so your balance table will reference the login table by the login ID, the balance table will have its own ID and the transaction table will contain the balance ID.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100