title: Wordpress Plugin Create Database Table
body: <p>Trying to create a pair of database tables within my table. Below is the code block that is being executed on the activation of my plugin. Wordpress reports that it's successful, however, when refreshing the database the employee table is not being created. The department table however is created successfully.</p>
  
  <pre><code>require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );     
  
      // create the database table.        
      global $wpdb;
      $charset_collate = $wpdb-&gt;get_charset_collate();
  
      $table_name = $wpdb-&gt;prefix . "plugin_department";
      $table_name2 = $wpdb-&gt;prefix . "plugin_employee";
  
      $sql = "CREATE TABLE $table_name (
          id INT(11) NOT NULL AUTO_INCREMENT,   
          name VARCHAR(255) NOT NULL,
          PRIMARY  KEY (id)
          ) $charset_collate;";
  
       $sql2 = "CREATE TABLE $table_name2 (
          id INT(11) NOT NULL AUTO_INCREMENT,     
          first_name VARCHAR(255) NOT NULL,
          last_name VARCHAR(255) NOT NULL,
          department_id INT(11) NOT NULL,
          PRIMARY  KEY (id),
          CONSTRAINT department_id
          FOREIGN KEY (id)
          REFERENCES plugin_department (id)
          ON DELETE NO ACTION
          ON UPDATE NO ACTION);
          ) $charset_collate;";                
  
      dbDelta($sql);        
      dbDelta($sql2);        
  </code></pre>
  
  <p>Ideas on how to resolve would be greatly appreciated.</p>