As example :
I have this scenario where we receive payments, a singular payment per family, and register those payments with it's amount in the DB.
The thing is that a family can move their loan from bank1 to bank2, only if they have 12 or more sequential payments.
As example if they have registered a payment for
oct, nov, dec, jan, feb, mar, apr, may, jun, jul, ago, and sept.
and feb didn't received any payment, the count will start over at march.
Coworkers are suggesting that the best approach is, in every payment registration count the total payments and register the total sequential payments in an int column called sequential.
as:
Payment Family Bank Date Sequential
---------------------------------------------------------
1200 2 1 10-22-2009 1
1200 2 1 11-22-2009 2
.
.
.
1200 2 1 08-22-2010 11
1200 2 1 09-22-2010 12
What I think, there must be an approach where the sequential column is needless, where if I want to validate if the last order by Date DESC 12 rows are sequential with only 1 month in difference.
any ideas?
Edited:
There will be million of
rowsin thistable.Also prefer to have only the dates in the tables and work with them at
application level