title: Java DB How to Insert Values for Foreign Keys into Table Column
body: <p>I am using java DB database and NetBeans 8.0 for a desktop application<br>
   I am also using a PreparedStatement to query the database.  </p>
  
  <p>below is the code for creating the tables.</p>
  
  <pre><code>CREATE TABLE ALUMNUS (
     ALUMNUA_ID INT NOT NULL PRIMARY KEY 
         GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), 
     FIRST_NAME VARCHAR (45),
     LAST_NAME VARCHAR (45),
     OTHER_NAME VARCHAR (100)
  );
  
  CREATE TABLE DUES (
     ID INT NOT NULL PRIMARY KEY 
         GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
     PAYMENT_YEAR DATE,
     AMOUNT DOUBLE,
     ALUMNUS_ID INT 
  );
  
  --FOREIGN KEY
  ALTER TABLE APP.DUES 
     ADD FOREIGN KEY (ALUMNUS_ID) REFERENCES APP.ALUMNUS(ID);
  </code></pre>
  
  <p>Now I want to insert, delete and update the foreign key values in APP.DUES table. what is the best option; trigger , stored procedure or the preparedstatement? </p>
  
  <p>An example will be good.</p>