I have a simple recipe ontology. The ontology consists of four object types and one interface.
Beginning with the materials used in a Recipe, for the purpose of discussion, let’s assume all materials divide into two object types: Liquid or Solid.
To capture the common properties and relationships of both Liquids and Solids and to establish that a Liquid and a Solid can sometimes be used interchangeably, we create an interface called Material. Thus:
Liquid implements Material
Solid implements Material
Moving to the object type Recipe…
Recipes are linked to object type Ingredient…
Each Recipe has many Ingredients
Each Ingredient has one Recipe
Ingredient contains amounts and…
Ingredient is linked to a Material (which, via the interface implementation, includes both Liquid and Solid object types)…
Ingredient has one Material
Material has many Ingredients
Here’s where I run into the problem. Foundry will not let me define a link type between the Ingredient object type and the Material interface. Only object types are available. No interfaces can be selected. Is there another way to achieve the same semantics? This is an extremely common modeling pattern. The real use case has dozens of Material subtypes, not just the two used here.
For your situation, you may consider defining a link type on the Material interface to many Ingredient objects. Then, in order to implement the Material interface, Liquid can declare that its link to Ingredient fulfills the Material → Ingredient link type.
Unlike object-object link types, interface links are modeled as constraints that object types implementing those interfaces must adhere to (interface links do not contain any implementation information like a many-to-many dataset or a foreign key property selection). The common example we use internally to describe this concept is that all Vehicles must have one or more Person objects that own that vehicle, whether the Vehicle is a Car, Motorcycle, or Boat. The details of that link type are not necessarily known when defining the Vehicle interface - perhaps Motorcycle has a “driver” property which is a foreign key into the Person object type, while Car has a many-to-many link.
Another difficulty with trying to implement links to interfaces is that Interfaces do not prescribe a primary key for the objects that implement them - a Car might have a Long property called “VIN number”, while Boats may have a String property called “registration”. There are other complications that can occur if different object types have overlapping primary keys. Supposing that Person is an interface, “jane.doe@example.com” maybe be the primary key of a Contractor and also the primary key of a Customer.
Interface links are still under active development, and are not yet supported outside of the ontology itself. Please refer to the docs for additional details: https://www.palantir.com/docs/foundry/interfaces/interface-link-types-overview (and I’ll go update the docs on our current levels of support to add some more specific details about links: https://www.palantir.com/docs/foundry/interfaces/interface-overview#current-levels-of-support)