Home → Using LincDoc 3.1+ → Configuring Storage Repositories → Configuring a SQL Repository
This topic describes how to configure your repository, both using the automated LincDoc capabilities as well as how to manually manipulate mappings and configure the repository database.
Proceed to one of the following sections below for more information:
The main purpose of the SQL Repository is to save the data and its corresponding generated document from your eForm or Document Package to a database, allowing you to retrieve the information (or generated document) at a later time as well as use other LincDoc features (such as search and reporting). Data from each field in your eForm or Document Package is sent to a specific column in a database table, as defined by the mappings within your repository's configuration (described throughout this topic). The generated document is also stored in the database.
The editing and configuration of a repository is done using the Configure dialog box, as described in the remainder of this topic. However, it is important to understand the underlying behavior of this process. Although the Configure dialog box may show you completed field mappings and database tables, none of these changes are actually implemented (pushed to the underlying database) until you execute the appropriate DDL statements. The system is careful to point out when exactly these statements are executed, and it will guide you on when/how to execute them. Further, you must save the mappings that are a part of the eForm's (or Document Package's) stored configuration (i.e., the normal pressing of the save button to save changes made to the eForm/Document Package). All of the steps necessary to complete the configuration process are described in this topic.
The Configure dialog box displays a "warning" icon (an exclamation point inside a red triangle) whenever there is some part of the mapping that needs attention. Clicking on this icon will show you a list of possible solutions and/or suggestions on how to fix the issue.
Tip: If the icon shown below is present in the lower right corner of the Configure dialog box, there are issues that may need your attention, such as missing mappings or non-created tables.
Tip: In some situations, it is safe to ignore this icon. For example, if there is an unmapped field being collected in the eForm or Document Package that you do not care to save to the repository's database.
A brief overview of the tasks involved with configuring a SQL Repository is described below.
The exact tasks you will use depend on your automatic mapping choices, your desire to manually map fields, how many changes you make to your eForm or Document Package, and the amount of database table customization you wish to undertake.
Once you add a repository to your model and connect to your database, you need to map your form fields to repository (database) fields. The first time you access your repository, you are presented with three options to help facilitate this mapping, based on your current needs and the amount of customization you desire.
Tip: This option is useful during testing, when your form has not been finalized, you are still adding, removing fields, or changing field types. Once your form is finalized, you should map the form's fields to database columns. It is also ideal if you want minimal involvement with the repository configuration process.
If any of the above items are altered after this step, and you have saved one or more forms into this mapping, you must take appropriate steps to re-map the field(s). This scenario almost always requiring manual intervention.
Important: If you do not care about losing data and documents for previously generated forms, you can always choose the option to delete the existing table(s) associated with your eForm, and then auto-map and create everything again. Use caution if you choose this route. For more information, see the remainder of this topic below.
Once you specify a mapping option as described in Selecting a Mapping Option above, or if you access your repository after creating the initial mappings, you can view your current mappings using the Configure dialog box.
Proceed to one of the following sections below:
Your currently defined, standard repository mappings can be viewed using the Configure dialog box's mapping tab, as shown below.
The left side of the dialog box shows the fields in your current eForm or Document Package (the Fields/sections entry), the type of data stored in the field (the type entry), and the database column to which the field is currently mapped, if any (the Column entry). The right side of the dialog box shows the database tables themselves, and provides the ability to manipulate these tables and their columns, if desired. Whenever possible, when tables are created automatically, LincDoc will attempt to use the LincDoc field names when defining the table column names.
You may also see the following items on your Configure dialog box (not all items will appear in all repositories):
Note: Fields used as search indexes (on the Search tab) are added to a separate table, as in the example above. Notice that the two search index fields are in table 6, while all other fields are listed in table 7.
If your eForm or Document Package uses multi-value fields, the mappings for these fields appear and are configured in their own tab on the Configure dialog box, separate from regular fields on the mapping tab. Each multi-value table in your eForm or Document Package will use a separate tab.
In the following example, one additional table for multi-value fields is present in the form, so only one additional tab is present.
An additional table is used because LincDoc doesn't know how many entries will be made to the multi-value fields, unlike standard fields which always take a single value. This additional table allows LincDoc to maintain data orthogonality (clean data with no duplication) within the repository's database.
The options available for these multi-value mappings are the same as those for standard mapping. They are simply displayed on a different tab and stored in a separate database table.
If you have any fields that are not mapped, and you do not want to manually map them, you can use the auto-map unmapped fields button to have LincDoc create the mappings for you.
If you choose to not have LincDoc automatically create your mappings, or if you edit your eForm or Document Package fields and want to manually map the new fields, you can do so by dragging the field entry (on the left side of the Configure dialog box) and placing it on top of the correct database column (on the right side of the dialog box).
Note: If a red "x" appears, instead of a green check mark, the mapping is not allowed because the field's type does not match the database column's type.
You can remove all existing mappings and tables, allowing you to restart the mapping process from scratch, using the clear mapping button.
When this button is clicked, all existing mappings and tables are removed, and the warning icon appears next to each field listed on the left side of the Configure dialog box.
Important: Although the tables are removed from the Configure dialog box, they are not deleted from the repository's database. If you recreate the tables, as described below, new tables are created in addition to the existing tables and numbered accordingly (although only the new tables are displayed in the Configure dialog box). If you want to delete the existing tables, you need to drop them.
You can now remap your fields using any of the following options:
It is possible to map multiple fields to the same column in a table. However, this task is considered advanced usage of LincDoc. For more information, see SQL Repository: Mapping Multiple Fields to a Single Column.
You can temporarily delete mappings, with the intent of re-mapping them at a later time, or you can have LincDoc permanently ignore the mapping of a field.
Proceed to one of the following sections below for details:
You can delete individual mappings, to remap them or to temporarily adjust mappings, using the "x" button.
This "x" button can be accessed from either the left side (field list) or the right side (database table list) of the Configure dialog box. The effect is the same, regardless of which side you use. The icon only appears once you have clicked a field or database column, as shown below.
When you click the "x" button itself, the mapping is removed and the warning icon appears in the field list on the left side of the Configure dialog box.
Once you have deleted a mapping, you can tell LincDoc to ignore it (via the ignored check box), which allows you to not map the field and avoid any potential errors that typically occur when fields are not mapped. In essence, you are telling LincDoc that you are aware of the missing mapping but you do not want to map the field.
Important: The data submitted via an ignored, unmapped field is not saved to your repository's database. As a result, when an existing, submitted form is accessed using the Data Entry View, any unmapped fields will be blank.
Several options are available for configuring your repository's database tables, allowing you to create customized tables and corresponding mappings, as necessary.
Proceed to one of the following sections below for more information:
If you have multiple tables displayed on the right side of the Configure dialog box, it may be helpful, at times, to collapse or expand different tables to limit the information displayed.
Clicking the blank portion of a table's title bar, to the right of the table's name and options, allows you to collapse and expand the table.
Once collapsed, only the table's title bar is shown.
You can expand the table by clicking the title bar again.
You can manually remove specific table columns using the remove column button within the column itself. This option is useful if you remove a field from your form and the corresponding table column is no longer needed.
You can add new tables, if you want more control over the number of tables in your repository's database or how your fields are distributed. New tables can either be entirely new to the repository or use other tables, already added to the repository's shared database, but not used by the current eForm or Document Package.
Warning: If you attempt to add in a table not created by LincDoc, it may not work (for example, due to custom table constraints already in place on the table). Mapping to non-LincDoc created tables is not officially supported, but it may work in many situations. You will know it is working if you generate a form and verify that you see expected results in the non-LincDoc table(s).
Tables are created using the add table to mapping button, which appears at the top of the list of tables on the right side of the Configure dialog box.
When this button is clicked, additional options appear.
If you select new table, a new table is added to the bottom of the table list on the right side of the Configure dialog box. You can rename the table, if desired.
If you select use existing table, a list of tables in the current repository database is displayed in the Select table dialog box, allowing you to choose one.
Once you click an existing table, it is added to the bottom of the list of tables on the right side of the Configure dialog box.
If you map a field to a specific type, but then change the field type in your form, the mapping will become invalid.
For example, if you accidentally define a date field as a text type, map the fields in your repository, and then change the date field to a date type, the existing mapping (to a text type field) will no longer be valid and must be remapped. A message, similar to the one show below, will appear when you save your eForm or Document Package.
You can fix these types of issues directly in the repository's Configure dialog box.
You can alter the name and type (text, integer, etc.) of an existing table column using the column's edit button.
Warning: Do not attempt to modify the column type if data already exists in the column unless you are a database administrator and completely understand all of the possible implications. The recommended procedure is to leave the existing column as is, and make a brand new column for the new type.
Note: You can also click the revert button (next to the save button) to return to the column's default name and type settings.
You can add columns to existing tables using the add column button for the desired table.
Note: You can also click the revert button (next to the save button) to return to the new columns default name and type settings.
Warning: The column is not actually created in the table when save is clicked. However, you will see the warning icon, which, if clicked, will display the commands to execute the appropriate DDL statements. These statements will create the column in the database table.
You can alter the name of an existing table using the rename button for the desired table.
You can view a table's data definition language (DDL) statements, which represent the statements that LincDoc uses to create the table(s) in the current mapping. In addition, you can initiate the execution of these statements. The intent of showing these statements is for advanced usage, such as when a database administrator is designing a custom back-end procedure and wishes to understand the structures (tables) that LincDoc is creating.
Tip: These commands are advanced options that will probably only be useful to database administrators.
You can remove a table from the Configure dialog box using the remove table from mapping button.
Important: This action removes the table from your mapping, but not from your database. That action requires that you drop the tables (using the drop tables button).
Once you have finalized your manual mappings and completely configured your repository's database tables (as necessary), you need to actually create the tables in your repository's database. Until you create the tables, they cannot be used by LincDoc. In effect, the Configure dialog box displays the "plan" for the mapping and repository database table creation. However, until the create tables button is clicked, this "plan" is not implemented and cannot actually be used by LincDoc to store data.
If your tables have not yet been created, but only appear on your Configure dialog box, they are marked with the warning icon, as shown below.
Important: You should use this option with care, as it will create new tables but will also overwrite any data present in existing tables.
You can permanently remove tables from your repository's database associated with the current eForm or Document Package. This action completely removes all tables and all associated data corresponding to the current eForm or Document Package. Other tables are not affected. It is useful if you have made major configuration changes to your mappings (such as changing the type used by fields) and need to recreate your tables.
Important: Use this option with extreme care. Once deleted, the tables and their data cannot be recovered.
Proceed to one of the sections below, based on how many tables you want to delete:
You can quickly delete all of the tables in your repository's database (associated with the current eForm or Document Package) using the drop tables button.
You can delete specific tables from your repository's database by accessing and executing specific drop table commands.
You can click the refresh button at any time to confirm that you are viewing the most recent field list, table list, and related mappings.
Once you have defined all of your mapping, configured your tables, and created your tables, you can test all of the items using the test button.
Once clicked, you are informed if all repository settings were successful or if there are issues that require your attention.
The settings available on the Configure dialog box's Options tab allows you to activate specific behaviors available with your repository.
The following options are available:
Note: This table is global to all eForms or Document Packages. Any eForm or Document Package that uses this option will have its XML data written to this same table. Usually the table is named client_id.default_document, where client_id is your client ID value.
You can determine whether or not a security policy is defined when a document is saved to your repository using the settings on the Configure dialog box's Security tab.
For more information on these settings, see Using SQL Repository-Specific Security.