michaellunsford Posted January 24, 2007 Share Posted January 24, 2007 About three years ago I made a table that has since been populated with hundreds of records and is in use by numerous websites. I want to completely redo the entire database structure -- going from a relitively flat format to relational. Of course, the problem is I don't want to recode all those websites.so, question: Can I turn the old table into an 'alias' table? That somehow refers to certain fields in the new table? That way the old stuff still works, and I can use the extended features for all the new stuff? Quote Link to comment https://forums.phpfreaks.com/topic/35453-making-myself-backward-compatible/ Share on other sites More sharing options...
artacus Posted January 24, 2007 Share Posted January 24, 2007 Yeah not an alias but you can use a view instead of an actual table. Quote Link to comment https://forums.phpfreaks.com/topic/35453-making-myself-backward-compatible/#findComment-167865 Share on other sites More sharing options...
fenway Posted January 24, 2007 Share Posted January 24, 2007 Just be careful... views don't support a great many features that tables do... but temporarily, it might be ok. Quote Link to comment https://forums.phpfreaks.com/topic/35453-making-myself-backward-compatible/#findComment-167994 Share on other sites More sharing options...
michaellunsford Posted January 24, 2007 Author Share Posted January 24, 2007 This would be a permanent thing. The old table was flat -- It was my first attempt at mysql while moving from a flat file database. There's nothing in there but varchar fields. Quote Link to comment https://forums.phpfreaks.com/topic/35453-making-myself-backward-compatible/#findComment-168061 Share on other sites More sharing options...
fenway Posted January 24, 2007 Share Posted January 24, 2007 Well, it's hard just to update half of a system... you'll be doing more work to "fake" it. Quote Link to comment https://forums.phpfreaks.com/topic/35453-making-myself-backward-compatible/#findComment-168086 Share on other sites More sharing options...
michaellunsford Posted January 24, 2007 Author Share Posted January 24, 2007 The only other option is to create a cron script that updates the old table from the new -- which works, I just thought there might be a mysql solution.Thanks anyway! Quote Link to comment https://forums.phpfreaks.com/topic/35453-making-myself-backward-compatible/#findComment-168093 Share on other sites More sharing options...
fenway Posted January 24, 2007 Share Posted January 24, 2007 Well, it's just not worth the effort it it's permanent... workarounds with MERGEs and VIEWs are just that. Quote Link to comment https://forums.phpfreaks.com/topic/35453-making-myself-backward-compatible/#findComment-168098 Share on other sites More sharing options...
michaellunsford Posted January 25, 2007 Author Share Posted January 25, 2007 how about this -- on the new table, can I make an alias field name?ie: `name` would equal `first_name` + ' ' + `last_name` Quote Link to comment https://forums.phpfreaks.com/topic/35453-making-myself-backward-compatible/#findComment-169373 Share on other sites More sharing options...
fenway Posted January 26, 2007 Share Posted January 26, 2007 I don't know what you mean.... Quote Link to comment https://forums.phpfreaks.com/topic/35453-making-myself-backward-compatible/#findComment-169598 Share on other sites More sharing options...
michaellunsford Posted January 26, 2007 Author Share Posted January 26, 2007 Instead of making an alias table, I thought to just upgrade the existing table with the new features. This would ensure backward compatibility with old stuff, but would require duplicate entry of certain fields.In the example, the old `name` field would become two fields `first_name` and `last_name`. To maintain backward-compatibility with the older PHP code, I figured I could just write it into the new code.So, the new PHP code (which uses the new fields) could combine the `first_name` and `last_name` fields and write it to the old `name` field. That way, the old PHP code would still function normally, even on the new fields. This does seem a bit round-about, so I was wondering if MySQL could do this automatically? Quote Link to comment https://forums.phpfreaks.com/topic/35453-making-myself-backward-compatible/#findComment-169819 Share on other sites More sharing options...
fenway Posted January 26, 2007 Share Posted January 26, 2007 Automatically, no... but with a complex DB wrapper class, maybe. Quote Link to comment https://forums.phpfreaks.com/topic/35453-making-myself-backward-compatible/#findComment-169943 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.