<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

	<title>Comments on: The [Title] bone's connected to the [Lyrics] bone...</title>
	<link>http://ask.metafilter.com/42345/The-Title-bones-connected-to-the-Lyrics-bone/</link>
	<description>Comments on Ask MetaFilter post The [Title] bone's connected to the [Lyrics] bone...</description>
	<pubDate>Mon, 17 Jul 2006 13:51:20 -0800</pubDate>
	<lastBuildDate>Mon, 17 Jul 2006 13:51:20 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: The [Title] bone&apos;s connected to the [Lyrics] bone...</title>
		<link>http://ask.metafilter.com/42345/The-Title-bones-connected-to-the-Lyrics-bone</link>	
		<description>MySQL/PHPmyAdmin for a band: How do I easily create a repository of lyrics that can be brought in for multiple albums?  &lt;br /&gt;&lt;br /&gt; Dreamhost server&lt;br&gt;
phpMyAdmin 2.8.0.3&lt;br&gt;
MySQL - 5.0.18-standard-log&lt;br&gt;
(I read somewhere that &quot;Relationships are off&quot;. I tried setting up relationships on another site and got nowhere with it.)&lt;br&gt;
&lt;br&gt;
My database background is Access, but I feel I&apos;ve got a handle on the whole normalization thing and so here&apos;s where I run into problems. A band has [Albums] albums contain [Songs] which have [Songs.Lyrics]. I would like to not have a long text field for each album that has all the lyrics (and their css encoding) - also, some songs are on a couple different albums.&lt;br&gt;
&lt;br&gt;
But how can I set up a many to many structure without relationships?&lt;br&gt;
&lt;br&gt;
Or how do I set it up with relationships in phpMyAdmin? All the documentation seems to say not to do it, or is so advanced, I can&apos;t tell if it&apos;s relevant.</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2006:site.42345</guid>
		<pubDate>Mon, 17 Jul 2006 13:41:40 -0800</pubDate>
		<dc:creator>Brainy</dc:creator>
		
			<category>php</category>
		
			<category>mysql</category>
		
			<category>database</category>
		
			<category>normalization</category>
		
			<category>band</category>
		
			<category>lyrics</category>
		
			<category>songs</category>
		
	</item> <item>
		<title>By: Doofus Magoo</title>
		<link>http://ask.metafilter.com/42345/The-Title-bones-connected-to-the-Lyrics-bone#651087</link>	
		<description>My two cents... you don&apos;t really need to specify relationships at the database level like in Access. As long as the relationships are implicit in the queries you write (e.g., by your choice of using a LEFT JOIN or an INNER JOIN), you&apos;re fine.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.42345-651087</guid>
		<pubDate>Mon, 17 Jul 2006 13:51:20 -0800</pubDate>
		<dc:creator>Doofus Magoo</dc:creator>
	</item><item>
		<title>By: utsutsu</title>
		<link>http://ask.metafilter.com/42345/The-Title-bones-connected-to-the-Lyrics-bone#651090</link>	
		<description>so, 1 [Album] has many [Songs], which each have one [Lyric](bear with me). The Lyric may also be attached to another [Song] on a different [Album], correct?&lt;br&gt;
&lt;br&gt;
This doesn&apos;t sound like a many-to-many, it is a one-to-many. It doesnt matter that an [Album] has many lyrics, because a [Song] only has one [Lyric].&lt;br&gt;
&lt;br&gt;
I would solve this by simply attaching a lyric to a song as a one-to-many. A song has one lyric but a lyric can be attached to many songs.&lt;br&gt;
&lt;br&gt;
So, [Songs] will have a field called LyricsID, which is a foreign key to [Lyrics]. The [Lyrics] table consists of LyricsID, LyricsContent and whatever else you need. This way, You can attach multiple [Songs] to the same [Lyrics] entry.&lt;br&gt;
&lt;br&gt;
Does this help at all? &lt;br&gt;
&lt;br&gt;
With a traditional relational database, you do not set up &quot;relationships&quot; so explicitly like you do in Access. You set up the primary and foreign keys to emulate those &quot;relationships&quot;. Really, it could be said that Access&apos; relationships is just a method of illustrating primary / foreign key pairs.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
The usual DB solution for a many-to-many is to use a third table in between.&lt;br&gt;
&lt;br&gt;
So, let&apos;s say that [Trainees] take many [TrainingPrograms], but a [TrainingProgram] also has multiple [Trainees]. The Primary Key of [Trainees] is TraineeID and the primary key of [Training Program] is TrainingProgramID. &lt;br&gt;
&lt;br&gt;
You create a third table to link the two. This new table will be called [TraineeTrainingPrograms] and will consist of two fields, TraineeID and TrainingProgramID.&lt;br&gt;
&lt;br&gt;
You can now write a SELECT query to get all of the [Trainees] in a [TrainingProgram] or all the [TrainingPrograms] taken by a single [Trainee].</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.42345-651090</guid>
		<pubDate>Mon, 17 Jul 2006 13:57:25 -0800</pubDate>
		<dc:creator>utsutsu</dc:creator>
	</item><item>
		<title>By: Brainy</title>
		<link>http://ask.metafilter.com/42345/The-Title-bones-connected-to-the-Lyrics-bone#651098</link>	
		<description>Doofus, So far I have been joining [Shows] to [Venues] in a pure query. But now I have the issue of having [Albums] that have [Songs] (in a particular order) that have [Lyrics]. So an album would have to be joined to songs in a many to many (with some way to keep track of the order)...hmmm, wait...i think im getting it....&lt;br&gt;
&lt;br&gt;
Would the best way of doing this be to create a [SongsOnAlbum] table that has albumID, songID, tracknumber and then write a query that joins [Songs] and [Albums] to that  table, sorting in tracknumber?</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.42345-651098</guid>
		<pubDate>Mon, 17 Jul 2006 14:03:54 -0800</pubDate>
		<dc:creator>Brainy</dc:creator>
	</item><item>
		<title>By: Brainy</title>
		<link>http://ask.metafilter.com/42345/The-Title-bones-connected-to-the-Lyrics-bone#651100</link>	
		<description>Oh, that second paragraph was more directed to utsutsu.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.42345-651100</guid>
		<pubDate>Mon, 17 Jul 2006 14:04:19 -0800</pubDate>
		<dc:creator>Brainy</dc:creator>
	</item><item>
		<title>By: AmbroseChapel</title>
		<link>http://ask.metafilter.com/42345/The-Title-bones-connected-to-the-Lyrics-bone#651107</link>	
		<description>I don&apos;t get why there&apos;s a separate table for the lyrics.&lt;br&gt;
&lt;br&gt;
Each song has only one set of lyrics, surely, so lyrics should just be a field in your songs table? Maybe you&apos;re overnormalised.&lt;br&gt;
&lt;br&gt;
The relationships should be handled as &lt;strong&gt;utsutsu&lt;/strong&gt; says, with a linking table -- I would have a table of &lt;strong&gt;songs&lt;/strong&gt;, a table of &lt;strong&gt;albums&lt;/strong&gt; and a linking table called something like &lt;strong&gt;songs_albums&lt;/strong&gt;.&lt;br&gt;
&lt;br&gt;
Each song would have an id, each album would have an id, and the songs_albums table would just be two columns of ids to say that song &lt;em&gt;x&lt;/em&gt; is on album &lt;em&gt;y&lt;/em&gt;.&lt;br&gt;
&lt;br&gt;
This bit raised a question too:&lt;br&gt;
&lt;br&gt;
&lt;strong&gt;&lt;em&gt;I would like to not have a long text field for each album that has all the lyrics (and their css encoding)&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;br&gt;
I don&apos;t know what &quot;css encodings&quot; means but that sounds like there&apos;s some double handling there too.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.42345-651107</guid>
		<pubDate>Mon, 17 Jul 2006 14:11:01 -0800</pubDate>
		<dc:creator>AmbroseChapel</dc:creator>
	</item><item>
		<title>By: AmbroseChapel</title>
		<link>http://ask.metafilter.com/42345/The-Title-bones-connected-to-the-Lyrics-bone#651109</link>	
		<description>&lt;strong&gt;&lt;em&gt;Would the best way of doing this be to create a [SongsOnAlbum] table that has albumID, songID, tracknumber and then write a query that joins [Songs] and [Albums] to that table, sorting in tracknumber?&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
&lt;br&gt;
I should Preview...&lt;br&gt;
&lt;br&gt;
Yes, that&apos;s the way.&lt;br&gt;
&lt;br&gt;
Three columns of numbers then, the third being the track number.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.42345-651109</guid>
		<pubDate>Mon, 17 Jul 2006 14:13:16 -0800</pubDate>
		<dc:creator>AmbroseChapel</dc:creator>
	</item><item>
		<title>By: utsutsu</title>
		<link>http://ask.metafilter.com/42345/The-Title-bones-connected-to-the-Lyrics-bone#651110</link>	
		<description>I would do it this way, adapt as you need to.&lt;br&gt;
&lt;br&gt;
[Artists]&lt;br&gt;
- ArtistID - primary key&lt;br&gt;
- ArtistName&lt;br&gt;
- whatever other artist info&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
[Albums]&lt;br&gt;
- AlbumID - primary key&lt;br&gt;
- ArtistID - foreign key&lt;br&gt;
- AlbumTitle&lt;br&gt;
- Year&lt;br&gt;
- Label&lt;br&gt;
- Anything else specifically related to the album&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
[Songs]&lt;br&gt;
- SongID - primary key&lt;br&gt;
- AlbumID - foreign key&lt;br&gt;
- LyricsID - foreign key&lt;br&gt;
- SongTitle&lt;br&gt;
- TrackNumber&lt;br&gt;
- whatever other info&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
[Lyrics]&lt;br&gt;
- LyricsID - primary key&lt;br&gt;
- SongID - foreign key&lt;br&gt;
- LyricsContent&lt;br&gt;
- Whatever else&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
[SongsOnAlbum]&lt;br&gt;
- SongID - primary key&lt;br&gt;
- AlbumID - primary key, note this is called a composite key when you use two fields&lt;br&gt;
- TrackNumber&lt;br&gt;
&lt;br&gt;
Now you just need to write some queries to be able to pull the data you need. I wrote this up assuming multiple artists, but you sound like you want this to be just for your own band. I would still keep the Artist table though, so you don&apos;t have to update every album if you need to change something that applies to your band.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.42345-651110</guid>
		<pubDate>Mon, 17 Jul 2006 14:13:19 -0800</pubDate>
		<dc:creator>utsutsu</dc:creator>
	</item><item>
		<title>By: Brainy</title>
		<link>http://ask.metafilter.com/42345/The-Title-bones-connected-to-the-Lyrics-bone#651121</link>	
		<description>&lt;strong&gt;Ambrose&lt;/strong&gt; &quot;CSS encodings&quot; was my &quot;I gotta hurry up and finish this question or I&apos;ll never post it&quot; way of saying that if I had all the lyrics embedded within an albums field, I&apos;d have to hard code in the class of title, of lyrics, as opposed to letting that all come out normally from the db.&lt;br&gt;
&lt;br&gt;
&lt;strong&gt;utsutsu&lt;/strong&gt;&lt;br&gt;
That&apos;s exactly the sort of visualization I needed! thanks!</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2006:site.42345-651121</guid>
		<pubDate>Mon, 17 Jul 2006 14:21:06 -0800</pubDate>
		<dc:creator>Brainy</dc:creator>
	</item>
	</channel>
</rss>
