MySQL key columns

Hi! If you have a key column in Appsheet, does the MySQL column need also be labelled key? Or does it matter?

I think that is highly dependent on the rest of your setup. At a minimum it will likely require an initial value of UNIQUEID() unless your MySQL DB autogenerates a key for that column automatically when a new row is added.

The MySQL key column can be called anything, however you must set it in your DB as Primary Key. I always set my key column labels to “id” with Primary Key and Not Null as the DB field options.

Also, I set the initial value to “CONCATENATE(UNIQUEID(),”-",NUMBER(NOW()))". This is to make the id even more unique.

I think this depends most on where records are created. If they are created in AppSheet, especially off-line, then the key in AppSheet should be text/ uniqueid().

I’ve worked in systems where the AppSheet key was different than the SQL key, when records are created from the SQL side. But occasionally they do need to be created from the AppSheet side, so you still need to use a separate uniqueid() column bedsides the row number.

Are all of your CRUD operations done through AppSheet? Or does the backend sync with something else?

Thanks for all the good tips guys!

1 Like