I'm currently trying to map a hashmap of name-value pairs in an entity. Seems easy enough, but I am working against a legacy schema which, of course, cannot be changed. The problem is the existing schema which in a distilled form is as follows:
table: ENTITY_TABLE
column: entity_id
column: hashmap_id
primary key: entity_id
foreign key: hashmap_id to table HASHMAP_TABLE
table: HASHMAP_TABLE
column: hashmap_id
column: name
column: value
primary key: (hashmap_id, name)
Normally the foreign key is in the HASHMAP_TABLE pointing back to the ENTITY_TABLE which would make things very easy. The problem is that the hashmap table is shared among many entities so there can be no foreign key in HASHMAP_TABLE.
How would you solve this assuming you can't modify the schema in any way?
|