title: UCanAccess - How to create a VARCHAR foreign key in MS Access? Getting "Missing columns in relationship" error
body: <p>I'm trying to create a master/detail relationship between two tables in MS Access using the UCanAccess JDBC driver.</p>
  
  <p>Both tables get created but the foreign key relationship fails with "<strong>Missing columns in relationship(Rel=master_table[[]] -> detail_table[[]])</strong>".</p>
  
  <p>Here is my test code:</p>
  
  <pre><code>try  {
  
      Connection connection = DriverManager.getConnection(dbURL);
      Statement statement = connection.createStatement();
  
      statement.execute("CREATE TABLE master_table ("
                          + "masterPK VARCHAR(32) PRIMARY KEY NOT NULL"
                          + ");");
  
      statement.execute("CREATE TABLE detail_table ("
                          + "detailPK LONG PRIMARY KEY NOT NULL,"
                          + "detailFK VARCHAR(32) REFERENCES master_table(masterPK) NOT NULL"
                          + ");");
  
  } catch (SQLException ex) {
      ex.getMessage();
  }
  </code></pre>
  
  <p>The statements work fine when I issue them inside Access, but not via UCanAccess.  What am I doing wrong?</p>
  
  <p>I've tried using different alpha and numeric data types, with and without size specifications, to no avail.</p>
  
  <p>I also read with interest <a href="https://stackoverflow.com/questions/58207198/missing-columns-in-relationship-when-creating-table">&quot;Missing columns in relationship&quot; when creating table</a> and tried the example after changing the foreign keys to LONG.  That didn't work, either.</p>
  
  <p>I'm using UCanAccess 4.0.4, MS Access (2007-2016 file format), OpenJDK 13+33 and OpenJFX 13.0.1, running in Apache NetBeans 11.1 on Windows 10.</p>
  
  <p>If it helps, the SQLException message is as follows:</p>
  
  <blockquote>
    <p>java.lang.IllegalArgumentException: Missing columns in
    relationship(Rel=master_table[[]] -> detail_table[[]])    at
    com.healthmarketscience.jackcess.impl.RelationshipCreator.validate(RelationshipCreator.java:183)
      at
    com.healthmarketscience.jackcess.impl.RelationshipCreator.createRelationship(RelationshipCreator.java:98)
      at
    com.healthmarketscience.jackcess.RelationshipBuilder.toRelationship(RelationshipBuilder.java:192)
      at
    net.ucanaccess.converters.Persist2Jet.createForeignKey(Persist2Jet.java:807)
      at
    net.ucanaccess.converters.Persist2Jet.createForeignKeys(Persist2Jet.java:761)
      at
    net.ucanaccess.converters.Persist2Jet.createTable(Persist2Jet.java:481)
      at
    net.ucanaccess.commands.CreateTableCommand.persist(CreateTableCommand.java:100)
      at
    net.ucanaccess.jdbc.UcanaccessConnection.flushIO(UcanaccessConnection.java:323)
      at
    net.ucanaccess.jdbc.UcanaccessConnection.commit(UcanaccessConnection.java:205)
      at
    net.ucanaccess.jdbc.AbstractExecute.executeBase(AbstractExecute.java:273)
      at net.ucanaccess.jdbc.Execute.execute(Execute.java:44)     at
    net.ucanaccess.jdbc.UcanaccessStatement.execute(UcanaccessStatement.java:157)
      at
    replicatesqliteschema.ReplicateSQLiteSchema.createContent(ReplicateSQLiteSchema.java:190)
      at
    replicatesqliteschema.ReplicateSQLiteSchema.start(ReplicateSQLiteSchema.java:271)
      at
    javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
      at
    javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
      at
    javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
      at
    java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
      at
    javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
      at
    javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
      at
    javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native
    Method)   at
    javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
      at java.base/java.lang.Thread.run(Thread.java:830)</p>
  </blockquote>