title: Foreign key for multiple tables and columns?
body: <p>I have been learning about Foreign keys and I wanted to know if the way I used it is correct in the example below:</p>
  
  <pre><code>CREATE TABLE user(
    id INT(11) NOT NULL AUTO_INCREMENT,
    username VARCHAR(50) NOT NULL,
    password VARCHAR(20) NOT NULL,
    PRIMARY KEY (id)
  );
  
  CREATE TABLE items(
    i_id INT(11) NOT NULL AUTO_INCREMENT,
    name TINYTEXT NOT NULL,
    price DECIMAL(8,2) NOT NULL,
    PRIMARY KEY (i_id)
  );
  
  CREATE TABLE user_purchase(
    i_id INT(11) NOT NULL,
    name TINYTEXT NOT NULL,
    id INT(11) NOT NULL,
    FOREIGN KEY (i_id) REFERENCES items(i_id),
    FOREIGN KEY (name) REFERENCES items(name),
    FOREIGN KEY (id) REFERENCES user(id)
  );
  </code></pre>
  
  <p>Thanks</p>
  
  <p>Now, how can I get maximum information from just the Foreign Key if I use, let's say, PHP?</p>