i’ve got two tables: members and members_data.
They both share the same unique auto increment id key and unique username fields.
I would like to merge the two tables into one members table, BUT I have ~50 scripts using members & members_data references. I also need some sort of alias setup to make my members_data queries point toward the new members table.
Is this possible?
You can effectively alias a table to another table by creating a view which just does SELECT * from the other table. This is however, not a good thing to do:
However, depending on how easy it is to test those “50 scripts” and how critical they are (Hint: very critical code which is difficult to test can put a real brake on effective development), creating the view MIGHT be a pragmatic thing to do in the short term (And short term solutions generally stay in place for years, or forever, in real applications).
I urge you, if it is in any way feasible, to change the “50 scripts” and carry out all the testing necessary to release such a change. In our team we have carried out changes (in a single release) which modified a lot more than “50 scripts”, but testing did of course prove challenging (or at least time-consuming).
As applications become larger and more complex, regression testing becomes more difficult. It is vital to think about it as much as possible, because refactoring WILL become necessary (assuming the app gets developed or maintained AT ALL), and because regressions are bad.
** All your tables, views etc, ARE scripted and in your source code management system, of course!