Cliff Evans - 2011-07-01

Just thought I'd post an example of how to add an FK relationship using the -meta tag as it took me a while to get it to work.  Hope it helps someone out there.

The main thing to keep in mind is that the data in the .xml file you pass to the -meta tag doesn't get merged with the data read from the database, so you have to include both sides of the relationship even though you probably already have both tables showing from the database connection.  So I got it working with something like the following:

<?xml version="1.0" encoding="UTF-8" ?> 
<schemaMeta xmlns:xsi="" 
 <comments>UnifiedDB World Database</comments> 
   <table name="instrument_measure">
     <column name="rowset_id">
       <foreignKey table="context_element" column="rowset_id" /> 
   <table name="context_element">
     <column name="rowset_id" />

One possible issue with this it that it currently only supports real relationships; by which I mean, it will assume that the


column in context_element is a PK and will mark it as such.  I've raised a feature request to allow you to mark the FK relationship as implied to allow adding logical relationships to the documentation of the database.  The request can be found here.