mysql - Handling Database History for Banking Accounts -


i creating banking database , have following problem here.

suppose customera has account number 4444 , through access details related the customer have separate primary key query on account number.

now, reason account number of customera changed 4444 5555 , new customerb given account number 4444.

i want database handle such change, approach should apply?

approaches developed are: assigning timestamp account number, me query efficiently find out current account number related customer name.

but cannot design query in which:

  • when access customerb using 4444 current details related b appear , not one's 4444 pointing customera, ,
  • customera when being accessed 5555 shows details including one's being stored in database 4444

i'm going assume educational exercise rather real banking application.

it doesn't make sense identify customer information account number alone. customers can have more 1 account , accounts can held jointly several customers, account number unlikely suitable key customers. suggest create customer number purpose.

i doubt bank imprudent enough allocate old account numbers new customers. possibly might happen after many years have elapsed since account number last used it's not need anticipate in database design. similarly, not expect delete or overwrite customer account numbers because account details, including account numbers, kept years (probably decades).


Comments