"Flat" vs "structured" Murmurations fields #34
Photosynthesis
started this conversation in
Library (fields and schemas)
Replies: 1 comment
-
like it - the proposed changes make sense to me. +1 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
What this is about
Some of the fields in the Murmurations library can be added as a single field in a schema, but include multiple "child" fields or sub-fields within the field definition. Examples of this include the
location
field (which includescountry
,region
, andlocality
as sub-fields), and thegeolocation
field (which includeslat
andlon
subfields). Fields that include sub-fields in their definition I'm calling "structured" fields, because the data that matches that field has internal structure to it. What I’m calling “flat” fields, on the other hand, do not have internal structure. One way to think about this is that data that matches flat fields can be put into a straightforward table, unlike structured fields.Example structured JSON data:
Example equivalent flat JSON data:
Issues with structured fields
Lack of flexibility for schemas
If a schema creator wants to include either:
The location field as defined won't suffice. An example of this is the KVM data, which has non-ISO country names, making the existing location field unusable.
Difficulty handling in aggregators
For most aggregators, it will be a lot easier to handle flat data than structured data. This is because in most cases data will be stored in tables, not as JSON documents. For array fields, structure is necessary. But for fields like location and geolocation, there doesn't seem to be any functional advantage to put these fields into a structure.
Can't pass schema field to RJSF for filters
Case in point: a common need for an aggregator would be to filter nodes based on some component of the location (often country). The convenient way to do this is to allow aggregator operators to choose fields from the schema, which then get passed to an RJSF form for client-side filters. But, this won't work if location data is grouped into a structured field.
Need pre-processing to enable location component search/queries
On the back-end, if an aggregator wants to allow querying by location components (which is a common need), they will generally have to do additional work to break apart the location data into flat data and store it separately.
Problematic for input/editing forms
Flat data is easier to handle for forms. Even in cases where we can use RJSF, making the form look good gets much more annoying when you have structured fields, because RJSF does a very poor job of adding convenient CSS selectors to fields, so you have to (at least in my experience) include some of the structural aspects in your selector to get at a specific input. When you're dealing with data of an unpredictable shape (as in any general purpose aggregator), this becomes problematic.
Advantages of structured fields
Proposed change
So, my suggestion is:
Beta Was this translation helpful? Give feedback.
All reactions