How to create a "facade" table?

Posted by tputkonen on Stack Overflow See other posts from Stack Overflow or by tputkonen
Published on 2010-03-25T12:00:26Z Indexed on 2010/03/25 12:03 UTC
Read the original article Hit count: 369

Filed under:
|
|

A legacy database contains a join table which links tables table1 and table2, and contains just two foreign keys:

TABLE_ORIG:
table1_id
table2_id

In order to utilize this table using JPA I would need to create a surrogate primary key to the link table. However, the existing table must not be modified at all.

I would like to create another table which would contain also a primary key in addition to the foreign keys:

TABLE_NEW:
id
table1_id
table2_id

All changes to TABLE_ORIG should be reflected in TABLE_NEW, and vice versa.

Is this doable in mysql?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about jpa