58 | | By using foreign keys we can force adherence to the REDCap object model and maintain the references even if the source data changes (although the SQL query itself would need to be updated in this situation). |
| 58 | project_name is easy, because you can search for it in the redcap_projects database where project_id matches (look at the URL for the project to see the "pid=XX" attribute. field_name is kind of easy, because you can search for it in the redcap_metadata table, where project_id matches and the human-readable string is in element_label. |
| 59 | |
| 60 | To find the form_name, you need to look for entries in the redcap_metadata where the project_id matches, the form_menu_description is not null (it will have the name of the forms in human readable format). Basically the first element in each form has a value in this column, and all other fields do not. |
| 61 | |
| 62 | By using foreign keys we could force adherence to the REDCap object model and maintain the references even if the source data changes (although the SQL query itself would need to be updated in this situation, unless you built a very complex query). |
| 67 | |
| 68 | The other approach is to create a project, with a data collection form to collect values and labels, and then query the redcap_data table for those entries. This is popular with the REDCap community but I (NH) really dislike it, as it puts metadata in the data table, which seems to be contrary to the database model of REDCap. |
| 69 | |
| 70 | To begin with, we will use the table definition above, and do manual lookups for the project, form, and field names. |
| 71 | |
| 72 | === Re-use of option list === |
| 73 | |
| 74 | Of course, sometimes you want to use the same list more than once. In this case, the form and field names in the database should relate to the question which makes FIRST use of the list. |