Open ferrisoxide opened 4 years ago
More info regarding attribute types:
https://www.gs1.org/voc/?show=properties
And possibly a source of property set definitions:
Am proceeding with this, using GS1's "bricks" as a reference
This is the basic model using in GS1
Segment --has many--> Family --has many--> Class --has many--> Block -- has many --> Attribute
| ^
| |
+--- core attribute ---+
Background
Already baked into the app is the notion of a property set, basic collections of facts about a product.
Each property set defines the name, type and potentially the title of product information elements:
This scheme is a bit clumsy and likely to become more complicated as more complex types are added. There is also no way currently in the system to validate data against property sets.
Proposal
1. Use JSON Schema
Rather than build out a complete type system, use the existing standards and tooling around JSON Schema. Under this model, a property set definition would look something like this:
There are numerous resources for validating JSON data, including multiple ruby gems:
We can probably push a lot of this down to the database level, validating / typing data within PostgreSQL itself:
2. Use Property Definitions From GS1
GS1 publishes standard property definitions for different product types and industries. Rather than invent our our, we should defer to the GS1 standards for property name and type information.
For example, the published Australasian_Liquor_Industry attributes includes a
liquorAge
integer type attribute.Other attributes include enums (
alcoholicStrengthDescription
), floats (standardDrinks
) and a number of attributes that are constrained by various rules - potentially mappable to JSON Schema regex type definitions.If we were to record data for alcoholic products - at least for the Australian market - we would map all these into a specific JSON Schema document for validating data.
3. Move Title Translations Into I18N
This may be an edge case, but there might be reasons to provide translations of property names. Rather than bake this into the schemas, we can push this off to Rails' I18N mechanism, translating based on keys, e.g.