Note: this Tech Tip applies to both 4D v11 SQL and 4D v12.
Since 4D v11 SQL a database structure file (4DB) is also itself a database as it contains a table for structure objects. This also implies that the 4D data engine is used to manage the structure file. Furthermore structure objects are loaded into the database cache as they are accessed (as explained in previous assets, see the See Also section).
Thus it is possible to lose structure changes if those changes were in the database cache, but not yet flushed to disk, and 4D quits unexpectedly. This can happen if 4D crashes or the user "force quits", for example.
Like many objects in the database cache, changes to structure objects are not logged to the database Journal file, so there is no way to recover them if the changes are not flushed. In this sense the structure is treated much like an external database (which is a new feature in 4D v12).
So how can the developer ensure that structure changes are saved? Ensure that the cache is flushed.
Here are some tips:
- Compiling the databases flushes the cache.
- Switching from Design Mode to Application mode (and vice versa) flushes the cache.
- Calling FLUSH BUFFERS flushes the cache.
- The cache is flushed periodically using the interval specificed in the Database Preferences (4D v11 SQL) or Settings (4D v12).
Take note of that last tip. It can be useful to set a short flush interval during development in order to ensure that structure changes are flushed as often as possible. Since there are unlikely to be large amounts of data changes during development, the increased flush frequency is unlikely to adversly affect application performance.