best practice to store reference data as constant

Data in reference tables can differ across environments, which directly leads to have different primary key values of same reference data in the tables across environments. But, knowing this fact, still some Appian applications use primary keys of reference data as constant, for example primary keys of workflow statuses are referenced using constants rather than their text value. If while deploying or during data migration, primary key changes, then code written using those constant references may break.

What is the best approach to code for above use case?

  Discussion posts and replies are publicly visible

Parents
  • In this case, I will utilize my own manually-created key value to reference the values.  I will still have a primary key on the table, but I don't care what it is unless I am grabbing it to update a value.  I maintain a 1-1 relationship of myKey to myValue manually. E.g.:

    primaryKey (identity, auto-increment)
    myKey (int)
    myValue (string)

    All code references values by myKey, deployments to new environments will insert/setup the data source as:

    (primaryKey,myKey,myValue)
    (null,1,Value1)
    (null,2,Value2)
    (null,3,Value3)

    All code to reference the values utilizes the myKey column as the 'key'.  If I need to update this list programmatically, I will return the primaryKey at runtime based on the myKey value.

Reply
  • In this case, I will utilize my own manually-created key value to reference the values.  I will still have a primary key on the table, but I don't care what it is unless I am grabbing it to update a value.  I maintain a 1-1 relationship of myKey to myValue manually. E.g.:

    primaryKey (identity, auto-increment)
    myKey (int)
    myValue (string)

    All code references values by myKey, deployments to new environments will insert/setup the data source as:

    (primaryKey,myKey,myValue)
    (null,1,Value1)
    (null,2,Value2)
    (null,3,Value3)

    All code to reference the values utilizes the myKey column as the 'key'.  If I need to update this list programmatically, I will return the primaryKey at runtime based on the myKey value.

Children
No Data