Related Records
How do we link related records into an entity?
In earlier versions of GoZync, you included related records in a portal on your sync layout and GoZync knew you wanted to include those related records in the same transaction as the parent sync layout. So if you were syncing an invoice, your sync layout included a portal of invoice line items.
That worked but was slower that it needed to be.
Starting in GoZync 4, each table you sync--related or parent gets its own sync layout.
You then use the Configuration tab in GoZyncHosted to indicate which tables are related to each other. Starting at the "child" table, click "edit" and then pick the table it is related to. (See the first screenshot below.)
You'll then be asked which field links the child table to the parent. You're being asked for the foreign key field in the child table: in our example, the related table is called "Invoice Data" and contains the invoice line items. It is related to Invoices and there is a field in each invoice line item that holds the primary key (the unique ID) of the invoice that line belongs to. That field is called "InvoiceData::Invoice ID" in our example and if you looked at the relationships in FileMaker it would be linked to the invoice's primary key: "Invoices::ID".
Be sure to click "edit" and fill out the screen above for both sides (hosted and mobile) of the table's row on the Configuration tab of GoZyncHosted.
When you're done you'll see the Configuration tab indent "related" tables below their parents, and indicate how they are related.
How do I undo a relationship and go back to syncing the table on its own?
Simply click in the "requires" column for that row and then click the "clear & cancel" button in the lower left of the "Requires...". That will undo the "requires" setting; do this on both the hosted and mobile sides of the table's configuration row and it will no longer be indented on the configuration tab and will be synced as its own table (provided you call a script to Zync it, or run "Zync It - Everything".
Syncing "Grandchildren"
Related syncing in GoZync only goes one "level" deep. It doesn't support synching of "grandchildren" (the engine would have to be exponentially more complex). In the case of three tables where the third is the grandchild of the first you'll have to choose one of those relationships for related synching and sync the third table independently.
What about related Join Tables or table with more than one foreign key?
The use case around join tables looks like this: imagine you have a table of addresses that is related to (that is a child of) both Companies and Contacts. Once you've wired up Addresses in GoZync mobile you can ask it to "require" either Companies or Contacts, but not both. So how can you set it up so when you sync a company or a contact you always get their addresses?
Here's how: