Number of problems related to counting records based on relationships
I'd like to be able to display information about the data in the database in a number of ways for my users. For example:
- Show each unique value in the datapoint_source field, and count the number of records in the table that include that value.
- Show each unique value in the datapoint_source field, but count the number of Observations on the Observations table are linked to Datapoints that include that value.
- For a found set of observations, show the different datapoint_source values that are linked to the found set and a count of how many times each unique datapoint_source value is matched to the found set.
I am not able to determine how these relationships or calculations should be defined. My database is below: