Data structure for new/old items codes

Hello,

I have a 2 tables

items codes: new item code, old item code

items quantities: item code, month, items quantity

There are several cases:

Case 1:

Z is the newer code, X is older code

X -> y -> Z

Case 2:

X -> Z

Y-> Z

Z is the newer code, X & Y are older code

I need to recalculate quantities table.

Case 1:

replace Z quantity by X quantity + Y quantity + Z quantity

replace Y quantity by X quantity + Y quantity

Before update:

x 10

Y 20

Z 30

After update:

x 10

Y 10+20=30

Z 10+20+30=60

Case 2:

replace Z quantity by X quantity + Y quantity + Z quantity

Before update:

x 10

Y 20

Z 30

After update:

x 10

Y 20

Z 10+20+30=60

How can I create a data structure to store 'items codes' with something like pointers (new code to old code)

so I will be able to find all the previous items codes of a selected item code ?

Thank you for your help

Re: Data structure for new/old items codes

You probably want a hash table, also know as dictionary or associative array.

Re: Data structure for new/old items codes

Hello,

Thank you for your answer.

Does hash table will be useful in this situation ?

a-> b-> c -> d -> e

f -> g -> h-> e

i -> e

I mean E is the current item code which replaces D,H,I.

A-I are old names in 3 chains.

I need to save for each letter (name) 12 numbers (demand for months).

In order to calculate E demand I need to sum A-I demands and add it to E demand (Edemand=Ademand+Bdemand+Cdemnd+...+Idemand)

What do you think ?

Thank you for your help