As a rule of thumb, we should never run database queries inside a for-loop! “Database transaction” is an expensive operation. For example, let’s say we designed an inventory software and it’s being used in production for a year, and reached 1,000,000 transactions. Suddenly, we learnt that we didn’t add the…