Uses of an anonymous union

Unions are used to minimize memory waste. For example, consider the following database-transaction class used to update a person's data. The key can be either a unique ID number or a person's last name, but never both at once:

Clearly, memory is wasted here since only one of the keys can be used in each transaction. An anonymous union (for instance, an embedded union having neither a tag-name nor an instance name) can be used in this case to avoid memory waste: