How to "increment" a number in a 1toN relationship
I have two tables (A & B) with a 1 to N relationship.
I would like to have an "incremental code" in table B grouped by its linked record in table A. For each new record in table A, the code in table B should start at "1".
What is the best way, using a script, to do this knowing that I will not create all records in table B at the same time?
A1 -> B1 : 1
A1 -> B2 : 2
A2 -> B3 : 1
A1 -> B4 : 3
Thanks in advance for your input!