I come from an SQL background and I'm still navigating fields/entities. I have a custom entity (analysis) to record information about a laboratory sample (what it is, when and where it was taken, and what analysis method was applied to it). The analysis will return many independent results. I was thinking of making a second entity (results) with an entity reference to the analysis entity, the name of the chemical that was measured, and the concentration that was measured.
However, could I instead make a custom field_type that is combination of the chemical name and its concentration? Then I could include this chemical_result as a field in my analysis entity with
->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
to include multiple chemical results in one analysis, right? When is it appropriate to use a custom field versus an entity?
I also have an entity called "chemical" that has information on chemicals of interest. If I use an entity for my results, I know I can make an entity_reference to the chemical entity, which would allow some more complex queries down the road. Can I do the same with a custom field? If not directly, I'm assuming I could program the add_analysis form to only allow certain values for chemical name when adding data to the result field, correct?