On 10/24/07, Steve Bennett stevagewp@gmail.com wrote:
Andrew wrote:
No need for the complex setup you envisiage. For mysql, at least, we could create a new table 'article_aliases', and "select aa_page from article_aliases where 'my_title' like aa_alias". Of course, we'd need to do some built-in, potentially expensive checking on the aliases that would be originally introduced, like checking if any other pages match the regex (if so, block the alias), and if the article title itself matches the regex (if not, block the alias).
On thinking about this some more, a single table should do it, with fields
page_id, alias_pattern, alias_expanded. Then saving a page is conceptually:
DELETE * from aliases where page_id = @page_id
INSERT aliases (page_id, alias_pattern, alias_expanded) SELECT @page_id, pattern, expanded FROM #temp_aliases
And searching is just: SELECT page_id FROM aliases WHERE alias_pattern = @query
I guess the pattern itself might not even have to be stored.
Steve