title: SQL database problems with addressbook table design
body: <p>I am writing a addressbook module for my software right now. I have the database set up so far that it supports a very flexible address-book configuration.</p>
  
  <p>I can create n-entries for every type I want. Type means here data like 'email', 'address', 'telephone' etc.</p>
  
  <p>I have a table named 'contact_profiles'.</p>
  
  <p>This only has two columns:</p>
  
  <pre><code>id           Primary key
  date_created DATETIME
  </code></pre>
  
  <p>And then there is a table called contact_attributes. This one is a little more complex:</p>
  
  <pre><code>id       PK
  #profile (Foreign key to contact_profiles.id)
  type     VARCHAR describing the type of the entry (name, email, phone, fax, website, ...) I should probably change this to a SET later.
  value    Text (containing the value for the attribute).
  </code></pre>
  
  <p>I can now link to these profiles, for example from my user's table. But from here I run into problems.</p>
  
  <p>At the moment I would have to create a JOIN for each value that I want to retrieve.
  Is there a possibility to somehow create a View, that gives me a result with the type's as columns?</p>
  
  <p>So right now I would get something like</p>
  
  <pre><code>#profile type    value
  1        email   name@domain.tld
  1        name    Sebastian Hoitz
  1        website domain.tld
  </code></pre>
  
  <p>But it would be nice to get a result like this:</p>
  
  <pre><code>#profile email           name            website
  1        name@domain.tld Sebastian Hoitz domain.tld
  </code></pre>
  
  <p>The reason I do not want to create the table layout like this initially is, that there might always be things to add and I want to be able to have multiple attributes of the same type.</p>
  
  <p>So do you know if there is any possibility to convert this dynamically?</p>
  
  <p>If you need a better description please let me know.</p>