sql - Any way to "shortcut" common joins or code blocks in MySQL? -


i have tables in normalized forms (i've started learning this, wildly guess i'm using 3rd normal form know i'm wrong, know of example code horribly written , potentially wrong), , there few common joins use across several queries.

for illustration's sake, let's have information on songs, this:

songs: song_id (pk) | song_title | first_artist | most_famous_artist  albums: album_id (pk) | album_title | version | format | year_released  song versions: song_version_id (pk) | song_id (fk) | artist | year_released  album tracks: album_id (pk, fk) | track_no (pk) | song_version_id (fk) 

and suppose pulling information on particular version of song, including name of song , album appeared on, keep writing:

from  song_versions sv  inner join songs s on sv.song_id = s.song_id  inner join album_tracks @ on at.song_version_id = sv.song_version_id  inner join albums on a.album_id = at.album_id 

or whatever case may be. know denormalize bit, , either combine couple of tables or have data duplicated across tables , make sure keep them consistent. there way keep data structure same, have shortcut refer combination of song/version/album without having write same join time? (especially if may want refer particular subsets of same join - e.g. albums containing famous version of particular song, or songs have appeared on album released after 2000.)


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -