Additional Keys

LabKey Support Forum
Additional Keys harris  2018-04-30 14:33
Status: Closed
 

The Edit Dataset Properties for the Study folder allows one additional key column. How can we add more than one additional key column? I'm currently using Creating Multiple Dataset Definitions from a TSV File. Is it possible to specify additional keys in this definition file?

 
 
Jon (LabKey DevOps) responded:  2018-04-30 14:59
Hello,

Datasets by default allow anywhere between one to three key columns depending on what the dataset is.

Typically the primary key columns are either:

- ParticipantId

- ParticipantId + Date (or VisitId)

- ParticipantId + Date (or VisitId) + a 3rd column of your choosing

More details here: https://www.labkey.org/Documentation/wiki-page.view?name=editDatasetProperties

Are the above options not suitable for your needs?

Regards,

Jon
 
harris responded:  2018-04-30 15:05
Hi,
Thanks for the quick reply. The 3rd column won't be enough for all types of clinical study data. We may need a 4th and sometimes a 5th (i.e., SUPINE/STANDING position, REPLICATE at a particular timepoint).

Regards,
Laura Harris
 
Jon (LabKey DevOps) responded:  2018-05-01 12:09
Hi Laura,

Thanks for confirming. Study datasets out of the box would not be able to support something like this.

If you have development resources, you could build your own module with a custom schema and tables that could utilize a combination of a primary key and unique constraints to accomplish what you need out of these tables, but these would technically not be study datasets since they would be living outside of the study schema.

https://www.labkey.org/Documentation/wiki-page.view?name=simpleModules

Regards,

Jon
 
Matthew Bellew responded:  2018-05-01 13:04
A common work around for this situation is to use the managed field feature to set rowid as the additional key. (additional key column / managed field: RowId).

This doesn't enforce the uniqueness constraint, but will allow you to import multiple rows per participant/visit.
 
harris responded:  2018-05-03 18:05
Hi,
Thanks. The managed field solutions seems ok, but I don't see that as an option. When I look at the managed field options, they are exactly the same as the data fields. Modification of the original data to make it fit in would not be a viable option for us. Is there something that I'm missing to get the RowId show up as a managed field?

Regards,
Laura
 
Jon (LabKey DevOps) responded:  2018-05-04 21:12
Hi Laura,

No, that's exactly what the managed fields is supposed to do, take an existing field and use it as a 3rd unique value to create a key in combination with the participant Id or the participantId/date (or participantId/visitId) combo.

So is adding any additional columns completely out of the question? Another possible option would be to combine the values in those multiple columns into one single column and treat that single column as the primary key, but this wouldn't work if you aren't able to modify the table to include additional columns beyond the original data.

Regards,

Jon
 
harris responded:  2018-05-04 22:11
Hi,
Thanks for the reply. I thought the data field option was supposed to be used as the 3rd unique key value. What is the difference between the managed field option and the data field option under the section for Additional Key Column? If we want to use LabKey, then it seems that we need to modify our original data to make it fit in if we have more than 3 keys. Is there any particular reason why LabKey allows a max of 3 keys? It's common to have more than 3 in clinical study data, especially if following CDISC standards.
 
harris responded:  2018-05-06 15:32
Hi Jon,
Please disregard my last message. We will be able to add a sequence column and use this as the extra key. I'll probably store the actual keys for reference in a List. Thanks for all of your help!

Regards,
Laura Harris