Free cookie consent management tool by TermsFeed Generate a Source for Your Record Type [Appian Records]
Generate a Source for Your Record Type

This page describes how to generate a database table at the same time that you're creating your record type.

Tip:  Already have a source configured? Learn how to choose an existing data source for your record type.

Overview

Creating relational database tables usually involves specialized knowledge of SQL commands and best data practices. With codeless data modeling in Appian, however, it's not just database administrators who can create and configure database tables. In this streamlined process, any developer can build and structure data perfectly for an application while configuring a record type.

Using our guided experience, you can quickly define the fields you want to add to your record type. We'll provide default fields like a primary ID field, and we'll suggest other commonly-used fields like a start date field. We'll also walk you through adding relationships to the record type and save you time by generating the common field that enforces that each relationship.

Then, we'll use the fields you've defined for your record type to automatically generate a database script to create the corresponding fields in a database table. Then we'll execute that script in your selected MariaDB data source. We'll use the same names you give the record fields, but we'll change them to meet the naming requirements of the database. For example, for the record field startDate, we'll create a START_DATE field in the database table. Then we'll execute that database script to create the table in your selected data source and give you the opportunity to download the auto-generated database script for future deployments.

Once you finish, your new data model will be reflected in your record type, and the database table will be synced in Appian.

Note:  To take full advantage of codeless data modeling, you'll need permissions to create a table in your selected database. If you don't have those permissions, you can still use the guided experience to generate a database script, which you'll then need to run in the database yourself.

To generate a database table from a record type:

  1. Start the guided experience
  2. Select a database.
  3. Configure your data structure.
  4. Add record type relationships.
  5. Review and edit your data model.
  6. (Optional) Prevent table creation.
  7. Save your changes.
  8. (Optional) Download the auto-generated database script.
  9. Click FINISH.

Start the guided experience

  1. In your application, create a new record type.
  2. On the Data Model page, click TELL US ABOUT YOUR DATA. The Configure Data Source dialog opens.
  3. Select New Data Model.

    New Data Model card

  4. Click NEXT.

Select a database

In this step, you'll select the relational database where Appian will create your table.

option to select database in the Create Data Model dialog

For Data Source, you can choose any MariaDB database connected to your Appian environment.

If your environment contains a single relational database, that database is selected and cannot be unselected.

When you've selected a database, click NEXT.

Configure your data structure

In this step, you'll add and configure the fields you want to include in your record type.

data structure configuration in the Create Data Model dialog

You can:

When you've finished configuring your data structure, click NEXT.

Review the default fields

For your new record type, we'll automatically provide fields like a primary ID field, so that you can follow data modeling best practices by default.

default fields highlighted in the Create Data Model dialog

The default fields include the following:

Field Type Description
id Integer The primary key for the record. Data sync requires a single primary key field per record type.
createdBy User The user who created the record.
createdOn Date and Time The date on which the user created the record.
modifiedBy User The user who last modified the record.
modifiedOn Date and Time The date on which the user modified the record.

Add suggested fields

In the Suggested Fields pane, we provide a list of fields that are commonly used in data structures.

suggested fields highlighted in the Create Data Model dialog

The suggested fields include:

Field Type
name Text
description Text
startDate Date
endDate Date
isActive Boolean
assignee User

To add a suggested field to the data structure, click the field in the Suggested Fields pane. The system adds the suggested field as follows:

  • If you've retained the default fields in default order, the system inserts the suggested field before the createdBy field.
  • If you've changed the order of the default fields, the system inserts the suggested field as the last field of the table.

Add a field

To add a single field to the data structure:

  1. Identify the row after which you want to add the field.
  2. In that row, click . The system adds a blank row immediately after the current row.
  3. Configure the properties for the field you added.

Add multiple fields

To add multiple fields:

  1. Identify the field after which you want to add multiple fields.
  2. In that row, click Add Multiple Fields.
  3. In the Add Multiple Fields dialog, enter a number between 1 and 20.
  4. Click ADD. The system adds the specified number of blank fields immediately after that field.
  5. Configure the properties for each field you added.

Configure field properties

For each field in the data structure, you can configure the following field properties:

blank row of field properties from the Create Data Model dialog

# Description
1 In the first box, enter a name for the field.
2 In the dropdown list, select a primitive data type appropriate to the field.
3 If you selected the Text data type and anticipate that the field will need to contain data longer than 255 characters, select the Long Text checkbox.

Note:   To reduce the likelihood of exceeding limits that MariaDB enforces on row data, we recommend adding no more than two Long Text fields to a record type. If you configure more than two Long Text fields, a warning displays in the field configuration dialog. You'll see a "row size too large" error if you attempt to run the generated script in the database.

Note:  You cannot change the primary key designation for the id field in this confirmation dialog. To change it after exiting this dialog, you'll need to modify the data source, then sync the record type.

Reorder fields

To reorder fields in the data structure:

  • Click to move a field up.
  • Click to move a field down.

You cannot change the order of the primary key field. Following best practice, that field is always retained as the first field in the table.

Keeping the other default fields as the last fields in the table also aligns with database maintenance best practices. However, you can change the order of those default fields as needed.

Remove a field

To remove a field from the data structure, click in the field row.

Add record type relationships

In this step, you'll add relationships to your record type. Record type relationships allow you to reference related data from your record type, which makes development faster and easier.

You can add relationships at any point in development, but defining a relationship here has many benefits. A relationship requires that your record type contains a common field that's used in both your record type and the related record type. If you add a relationship at this point, Appian can write that common field to the data source as part of the initial table creation. You can always add the relationship later, but depending on the method you use to make the change, you might have to manually add the common field to the data source.

What's more—when you add the relationship now, Appian can automatically generate a common field for you based on the relationship type you select.

To add a relationship:

  1. Select the record type to which you want to establish a relationship:
    • To select a record type in the current application, click a record type listed in the Suggested Record Types pane. For example, see Employee in the image above. If your application doesn't have any record types yet, this pane is blank.
    • To select a record type in the current environment:
      • Click NEW RELATIONSHIP in the Relationships pane.
      • Search for and select a record type in the Related Record Type field.
      • Click NEXT.

    The Add Relationship to <Record Type> dialog displays. For example:

    Add Relationship to Project dialog

  2. Under Relationship Name, enter a name for the relationship. This is how you’ll reference the relationship to access the related record fields.
  3. Under Relationship Type, select One-to-Many, Many-to-One, or One-to-One. By default, Many-to-One is selected. Learn more about supported relationship types.
  4. Under Common Fields, choose the fields to enforce the relationship type. The common fields can be of type Text, Number (Integer), User, or Group, and the common fields must be the same data type.

    In this dialog, the common fields default to the following settings, based on the relationship type:

    Relationship Type Common Field in Current Record Type Common Field in Related Record Type
    One-to-Many The primary key field of the current record type. No default setting. Select a field of the same data type as the primary key field of the current record type.
    Many-to-One An auto-generated field that matches the primary key field of the related record. For example, see employeeId in the example above. The primary key field of the related record type.
    One-to-One An auto-generated field that matches the primary key field of the related record. The primary key field of the related record type.

    You can change the names of auto-generated fields and select different common fields for both the current and related record types. However, you can only select fields that meet the criteria for the relationship type. For example, the common field in the one-side record type of a one-to-many relationship must be the primary key field.

  5. Click ADD.

  6. (Optional) Remove a relationship by clicking .
  7. Click NEXT.

Review and edit your data model

In this step, you'll review the data model you've configured and make changes as necessary.

The review page includes the following elements:

  • Fields tab: Lists the fields you want to add to your record type and the new database table. In this tab, you can add fields, configure field properties, reorder fields, and remove fields the same way you would in the earlier step.
  • Relationships tab: Lists the relationships you want to add to your record type. In this tab, you can add or remove relationships the same way you would in the earlier step.
  • Relationship Diagram: Displays a diagram of the relationships you added in the earlier step.

If you're experienced with database scripts, you might want to preview the auto-generated database script at this point. To do so, clicking Preview database script.

Before you continue, verify whether you want Appian to create a database table at this time.

Prevent table creation (Optional)

By default, the system will use the auto-generated database script to create a table in the database you selected earlier. You'll just need to keep the Create Table option selected.

However, under certain conditions, you might want to prevent Appian from creating the table. For example, you might need to make modifications to the script like editing the field names to meet database administration requirements or adding foreign keys and constraints.

In that case, you can prevent the system from creating the table, while still taking advantage of the guided experience to generate the basic script.

To prevent table creation, unselect the Create Table checkbox.

Save your changes

Click SAVE CHANGES to save your changes to the record type.

If the Create Table checkbox is selected, Appian will save the data model for the record type and create a new table in the database.

If the Create Table checkbox is unselected, Appian will save the data model for your record type, but make no changes to the database itself. Because the table does not yet exist in the database, the sync will fail for your record type. As a result, error indicators of the failed sync will display in the record type until you create the table in the database and trigger a full sync.

Download the database script (Optional)

After Appian successfully saves the changes to your record type, you have only one step left: deciding whether to download the auto-generated database script.

Record Type Updated Successfully message

You can use the database script to:

  • Create the new table directly in the database if you prevented table creation earlier.
  • Deploy any application that uses the record type to another environment. To do this, you can include the script in a deployment package or run the script in the target environment prior to a manual deployment.

By default, the Download database script is selected, and the system will download the script when you click FINISH.

If you do not want to download the script, unselect the Download database script checkbox before clicking FINISH.

Caution:  The auto-generated database script is not saved in Appian, so we strongly recommend downloading the script now and storing it locally.

Open in Github Built: Fri, Apr 19, 2024 (06:08:09 PM)

Generate a Source for Your Record Type

FEEDBACK