title: MySQL: How to insert values in a table which has two foreign keys
body: <p>I'm using MySQL with NodeJS and i have a table that looks like this:</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS `keycomponent`.`Transaction` (
    `TransactionID` INT NOT NULL,
    `TransactionDate` DATE NOT NULL,
    `Amount` MEDIUMTEXT NOT NULL,
    `CreationDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `TransactionDescriptionPK` INT NOT NULL,
    `FilePK` VARCHAR(255) NOT NULL,
    PRIMARY KEY (`TransactionID`),
    UNIQUE INDEX `TransactionID_UNIQUE` (`TransactionID` ASC),
    INDEX `FilePK_idx` (`FilePK` ASC),
    INDEX `TransactionDescriptionPK_idx` (`TransactionDescriptionPK` ASC),
    CONSTRAINT `TransactionDescriptionPK`
      FOREIGN KEY (`TransactionDescriptionPK`)
      REFERENCES `keycomponent`.`TransactionDescription` (`TransactionDescriptionPK`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION,
    CONSTRAINT `FilePK`
      FOREIGN KEY (`FilePK`)
      REFERENCES `keycomponent`.`File` (`Filename`)
      ON DELETE NO ACTION
      ON UPDATE NO ACTION)
  ENGINE = InnoDB;
  </code></pre>
  
  <p>it contains two foreign keys and when i try to insert values into another table  i get this error</p>
  
  <pre><code>Error: ER_NO_DEFAULT_FOR_FIELD: Field 'TransactionDescriptionPK' doesn't have a default value
  </code></pre>
  
  <p>shouldn't the column automatically get the primary key from the other table ?</p>
  
  <p>my query '</p>
  
  <pre><code>    'INSERT INTO Transaction '+
                'SET TransactionID = ?, TransactionDate = ?, Amount = ?, TransactionDescriptionPK = ?, FilePK = ?',
  [transId,date,amount,"primary key to the TransactionDescription table","primary key to the File table"]
  </code></pre>