plantbreeding / BrAPI

Repository for version control of the BrAPI specifications
https://brapi.org
MIT License
55 stars 32 forks source link

One study in several trial #594

Open cpommier opened 5 months ago

cpommier commented 5 months ago

Currently, trial has many studies and one study belong to a single trial. As mentioned, trial can be mapped to other concepts in other systems, and in particular to project and dataset.

In those cases, a study can belong to several trial/datasets. There is therefore a need to update trial<-->study to many to many

Gabriel-Besombes commented 5 months ago

Isn't there a similar issue with program and trial?

BrapiCoordinatorSelby commented 5 months ago

Putting down some thoughts, this is pretty simple to solve from a technical point of view, but will add more complexity to the spec.

New Parameters will be added, to search for programs and trails based on study GET /programs?studyDbId=xyz&trialDbId=abc GET /trials?studyDbId=xyz Technically, this would be enough. with these parameters you can find all the studies per trial and all the trials per study.

Optionally, we can add arrays to all the entities "studies": [{ "studyDbId" : "xyz", "studyName" : "XYZ" }] "trials": [{ "trialDbId" : "abc", "trialName" : "ABC" }] "programs": [{ "programDbId" : "123", "programName" : "P123" }] all three arrays could be added to all three entities, or useful subsets

Gabriel-Besombes commented 5 months ago

Adding the new parameters would only fix the issue in the search queries, not in the post/put ones if I'm not wrong.

daveneti commented 5 months ago

When we were implementing GraphQL for BrAPI we weighted up the merits of adding parameter to search queries and/or updating the response. In GraphQL you have the option of defining what fields are returned in the response, which is not possible in OpenAPI. So adding for example arrays of studies, trials, programs etc in the case of many to many relationships can lead to performance hits if you always need to do the join to return these. In some parts of BrAPI you have the includeXXX parameter which allow the response to to different. Also you have the 'sub-query' option, for example you could have the endpoint GET /studies/{studyId}/trials instead of adding a trials array to study. I think this is a better way to manage many to many relationships in OpenAPI, but then there is an additional enpopint to implement. Also, what if you have many studies to query. In that case you have to use the studiies search enpoint with a trial filter parameter.

So in summary for many to many relations (and one to many relations that have lot of results), I would propose