mysql - How can i store old and new updated value at same time? -


i have built database:

slots(user_id,current_slots,old_slots,current_expiry,old_expiry);    credit_transfer(transfer_id, sender_id, receiver_id,date,num_slots);   history(history_id, reseller_id,transfer_id) 

user_id coming user table.
sender_id , receiver_id foreign keys of user_id.
reseller_id foreign key of user table

when user buys new slots, entry recorded in history table new history id, i.e slots table.

the problem facing when new history_id added, i.e when new slots added, slots previous history id updated.

how can change design, old history id row doesn't change.

well simplest thing place unique constraint on userid. ensure not have duplicates same user entry.

i not sure language using or if you're using stored procedures. in case, detect duplicate/unique constraint exception , update slot count or expiry information.


Comments

Popular posts from this blog

r - Trouble relying on third party package imports in my package -

Payment information shows nothing in one page checkout page magento -