CombinedEntityClass

CombinedEntityClass[class1,class2,prop]

represents a class of entities obtained by combining the properties of those pairs of entities from class1 and class2 for which the value of the property prop is the same for the two entities in the pair.

CombinedEntityClass[class1,class2,prop1prop2]

combines pairs of entities from class1 and class2 for which the value of prop1 of the entity from class1 is the same as the value of prop2 for the entity from class2.

CombinedEntityClass[class1,class2,{pspeca,pspecb,}]

combines pairs of entities for which all the property specifications pspeck agree.

CombinedEntityClass[class1,class2,f]

combines pairs of entities for which the application of the entity function f yields True.

CombinedEntityClass[class1,class2,spec,"jspec"]

uses "jspec" to determine when to allow entities with missing properties to be included.

Details

  • EntityProperties[CombinedEntityClass[class1,class2,]] is effectively Join[EntityProperties[class1],EntityProperties[class2]].
  • In CombinedEntityClass[class1,class2,f], the function f must be of the form EntityFunction[{e1,e2},], where e1 and e2 stand respectively for entities in class1 and class2.
  • The properties in the result from CombinedEntityClass[class1,class2,] are of the form EntityProperty[typei,], where the typei are the entity types of the classi.
  • CombinedEntityClass["alias1"->class1,"alias2"->class2,] can be used to give properties of the form EntityProperty["aliasi"->typei,].
  • In CombinedEntityClass[class1,class2,], the classi must be distinct. CombinedEntityClass[class,"alias"->class] can be used for identical classes.
  • In CombinedEntityClass[ca,cb,spec,"jspec"], the join specification jspec determines which entities ai from class ca and bj from class cb should be kept, depending on whether the condition defined by cond is met. The possible join specifications are the same as for JoinAcross:
  • "Inner"keep only ai, bj for which the condition is met (default)
    "Left"allow ai for which there is no matching bj
    "Right"allow bi for which there is no matching aj
    "Outer"allow both unmatched ai and bj
  • When a property value is absent, Missing["Unmatched"] is used in its place.
  • CombinedEntityClass[class1,class2,EntityFunction[{x,y},True]] effectively implements the SQL CROSS JOIN. It is roughly equivalent to Outer[Join,] applied to the "PropertyAssociation" obtained from both classes.

Examples

open all close all

Basic Examples  (6)

Combine elements of period 1 with their isotopes to compare their atomic masses:

In[1]:=
Click for copyable input
Out[1]=

A CombinedEntityClass has all the properties of both classes:

In[1]:=
Click for copyable input
Out[1]=

Combine elements and isotopes according to a predicate:

In[1]:=
Click for copyable input
Out[1]=

Different join specifications will result in different behavior with respect to unmatched entities:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=
In[3]:=
Click for copyable input
Out[3]=
In[4]:=
Click for copyable input
Out[4]=

When combining the same type with itself, an alias must be used:

In[1]:=
Click for copyable input
Out[1]//Shallow=

When used with relational-database-backed entities, a CombinedEntityClass is effectively equivalent to a JOIN statement:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]//Shallow=

Scope  (2)

Introduced in 2019
(12.0)