Reputation: 1423
I'm using SQL Server to store users uploaded songs.
Each song has an id(simple auto increment number) and a name.
I want to use URL Rewriting to query some song, like this:
http://wwww.mysite.com/song/song_name
The problem is that I also want to enable users to change their songs name and still use the old URL.
I thought of creating another table whice will contain the old names and then check for some song name in both tables, is that a good solution?
Upvotes: 0
Views: 224
Reputation: 6219
Create table song_names
with fields
songs
table)If you get a name of the song from link, you can find it in this table, so you can find a song in songs
table. The actual song name will be the one in song_names
table with given song_id
and most recent creation_date
.
Upvotes: 0
Reputation: 37587
A better approach may be to create a single URL table that contains the URLs and the song it's tied to:
SongID: URL:
1 song_name
1 song_name_change
2 other_song_title
This approach would:
Upvotes: 1
Reputation: 2389
Additionally to the existing songs
table I would:
alias
with columns
alias
- would contain song names, original and modifiedtarget
- id of the song, reference to songs
tablemain_alias
to songs
table; it would reference the main alias (i.e. the last edited one), so that when You can redirect people using old aliases or going to the song via its id.Then, You could access the song via
URL/[song_id]
- find song by id + rewrite the URL to main alias
URL/old_song_name
- find song by alias + rewrite the URL to main alias
URL/new_song_name
- same as aboveURL/even_newer_song_name
- same as aboveAll in all, you can have unlimited number of names pointing to the same song.
Upvotes: 0