Updating record when referenced by multiple data structures

后端 未结 7 1283
独厮守ぢ
独厮守ぢ 2020-12-10 06:50

Suppose I have a record, e.g. Person, and I want to be able to look this person up through multiple data structures. Maybe there\'s an index by name, another in

7条回答
  •  忘掉有多难
    2020-12-10 07:27

    I would probably just update every lookup structure with the new value. Perhaps grouping the structures in a record and providing a global update function.

    Or perhaps you could designate one of the search criteria as "primary", and have the values in the other lookup maps point to the "primary key" of the object, instead of to the object value itself. That would cause one additional lookup for each access by non-primary key, though.

提交回复
热议问题