I've got an old database dropped in my knee and it's not very well modeled. The crappy modelling is taken care of in an overly complex software application, but I need to work more closely to the database.
Instead of understanding how foreign keys and relations work, the database is modeled like this:
Table1
containsID_1
,Value
Table2
containsID_2
,AnotherValue
,ID_1s
where ID_1
is an INT and ID_1s
is a varchar containing a pipe-separated string of references to ID_1 (i.e. '1|4|5', meaning it is referenced to rows where table1.ID_1 is 1, 4, or 5)
Now, I need to join these two tables rather than have an application parse through them and link them programatically. At the same time, I can't modify the db-model itself since it will break the application.
Bsaically, I need to emulate a many-to-many relation with what I've got.
Does anyone have an idea of a somewhat solid way of doing this?
(In the future, there is a plan to basically redesign the database and use views as an abstraction for the application.)