SchemaEditor and OneToOne relations : clearing up a bit of ambiguity

Using Dovetail SchemaEditor to add a new relation to your schema is super easy.


For example, here’s my schema script for adding a new one-to-one relation between the modem table and the user table:



What’s nice is that I only have to define the relation once in the schema file, as opposed to other tools (ddcomp, DD Editor, SchemaManager) where I would have to add the relation to the file in two places (as a relation under both the modem table and as a relation under the user table).


But, there is a bit of ambiguity here – which side is the primary side (OTOP) and which side is the foreign side (OTOF)?



The foreign side will be on the table/name, and the primary side will be inverseTable/inverseRelationName.


So in the example above, the modem2user is the OTOF, and user2modem is OTOP.


This means that the physical column will be created on the primary side. In the example, the user table will get a column named user2modem, while no changes will be made to the modem table.

Schema Meta-data (ADP Tables)


Here’s what it looks like in BOLT (which reads it from the ADP tables):




Notice that modem2user is the OTOF side of the relation.

Physical Tables


We can see that there’s now an actual user2modem column on the user table:




And that the modem table did not get any new columns:



Other way ‘round


If you want to have the relation go the other way, i.e. you want the physical column to exist on the modem table, then simply sway how you define the relation, like so:





Hopefully this clears up any ambiguity about OneToOne relations using SchemaEditor. We’ll also be updating the SchemaEditor docs with this information as well.