As explained in Stage 3 of the tutorial, a Database Record structure is automatically associated with a matching database table.
This means that:
The mapping implies by the tableName property allows you to interact with existing database tables (or views). If you properly set tableName and the names of fields in the Database Record, the basic database actions like Insert or Find will properly access the correct fields in the correct tables/views.
However, you can also work the other way around - define a Database Structure and let Tersus create for you automatically the corresponding database table. By default, when you start your application, the Tersus Server searches you model for all Database Structure models in use and checks the tableName property of each of them. If a corresponding table or name does not exist in the database, the Tersus Server creates such a table automatically with all the required columns. Each column in created with the data type implied by the type of the corresponding field in the Database Structure.
When the table is automatically created in the database, a primary key is always set. The primary key is either the set of columns whose corresponding fields have the property primaryKey=true, or the first column (if all fileds have primaryKey=false).
If you prefer to manage the tables in your database explicitly, you can configure Tersus not to automatically create database tables when starting the application. In the application's configuration file, set to "false" the init_db parameter of the relevant data source (see Connecting to an External Database).
Note: To create a configuration file, use http://applications.tersus.com/Configurator.
Tersus does not create automatically database views. If you want a Database Record structure to map toa database view, you will have to create the view before launching the application.
Be careful: If you fail to create the database view in advance, and the init_db parameter is set to "true", Tersus will create a corresponding database table (not a database view).
When the init_db parameter is set to "true", any field you add to the structure of a Database Record will cause addition of a corresponding column to the corresponding database table.
Note, however, that for the change in the database table to take place, you should stop your application in the Tersus Server and then restart it. Simply saving the model is not enough, since the creating of missing database tables (or missing columns in database tables) is performed when the application is started.
Be careful when renaming field names (or the structure of a Database Record). You may run into inconsistencies between the model and the database, unless you have explicitly set the columnName property as explained above. If you don't have any important data in your database yet, you can simply delete it. Otherwise, you'll need to make matching changes in the model and in the database.
Specifically, if a table has already been created in the database, changes to the primaryKey property of the fields in the corresponding Database Record will not be applied to the database table, and you will need to perform the matching change manually in the database.
Table Wizard makes it easy to create and modify Database Record structures. But it is only a shortcut to modifying your model - it does not change anything in the way Tersus applications are executed, so if you change the structure of some Database Record through the wizard, it will have the same implications as if you have made these model modifications directly (remember to restart the application for your changes to take effect, and be careful with field renaming).
For best results, use the Firefox browser..