title: Inserting data with foreign keys and avoiding duplication
body: <p>I'm very beginner at MySQL and have just started to play around with foreign keys and <code>INNER JOIN</code> operator.
  So I've made a few tables like:</p>
  
  <pre><code>CREATE TABLE `models` 
  (
  `id` TINYINT UNSIGNED NOT NULL AUTO_INCREMENT, 
  `name` VARCHAR (255) NOT NULL, 
  `price` MEDIUMINT UNSIGNED NOT NULL,
  PRIMARY KEY( `id` )
  );
  
  CREATE TABLE `vendors` 
  (
  `id` TINYINT UNSIGNED NOT NULL AUTO_INCREMENT,  
  `name` VARCHAR (255) NOT NULL,
  `id_model` TINYINT UNSIGNED NOT NULL,
  PRIMARY KEY( `id` ),
  FOREIGN KEY (`id_model`) REFERENCES models(`id`)
  );
  
  CREATE TABLE `cars` 
  (
  `serial_number` MEDIUMINT UNSIGNED NOT NULL,  
  `id_vendor` TINYINT UNSIGNED NOT NULL,
  FOREIGN KEY (`id_vendor`) REFERENCES vendors(`id`),
  PRIMARY KEY( `serial_number` )
  );
  </code></pre>
  
  <p>I know how to get output with that. However, the problem is that I don't know how to insert data properly. All I can do is insert data table by table. But how to do it in one query, and if I am inserting Honda Civic and already have Honda Accord, for example, wouldn't it duplicate Honda vendor in the database?</p>