title: Database modeling Playlists with Songs
body: <p>I am trying to figure out the logic of setting up models for a <code>Playlist</code> and <code>Song</code>.</p>
  
  <p>So far I have:</p>
  
  <p><code>User has_many :playlists, has_many :songs</code></p>
  
  <p><code>Playlist belongs_to :user, has_many :songs</code></p>
  
  <p><code>Song belongs_to :user</code></p>
  
  <p>I'm not sure how I should go about associating that a Song can belong to many Playlists. </p>
  
  <p>Would I want to setup a <code>has_and_belongs_to_many :playlists</code> and setup a join table or should I do a <code>has_many :through</code> association?</p>
  
  <p>Can you do a HABTM association on just one model or does it have to be declared on the two models you're relating? It doesn't sound right to have a <code>has_and_belongs_to_many :songs</code> association on the <code>Playlist</code> model.</p>
  
  <p>The relationship between <code>User</code> and <code>Song</code> works fine, I'm just trying to implement <code>Playlist</code>. Of course, a song does not have to belong to a playlist.</p>