Composite primary key in Retool App Table Component

  • Goal: Have a composite primary key in retool table component-->

I have a Retool table component which uses an SQL query as the datasource. My table, called ADJUSTMENTTARGET has a composite primary key, comprised of two foreign keys, AdjustmentID and TargetID. In my retool table component, I am only able to select one primary key, which has lead to a few weird issues.

An example of this weird issue is all of my records being selected/highlighted in my table. A screenshot of this is shown below.

Any help would be appreciated.

We have done something similar by adding a new calculated column to the SQL table "PrimaryKeyValue" (which will just be a concatenated AdjustmentID + TargetId) and then using it in the generated Retool table as the PK. A bit of a workaround, but it has served us well so long as it remains truly unique.

Thank you Pyrrho, that sounds like a good workaround, we will experiment with this workaround and provide an update here shortly.