represents an empty entity store for entities of type "type".


represents an entity store for entities of type "type" with properties and values defined by data.


represents an entity store for entities of multiple types.


constructs an entity store from the schema of an external database.


constructs an entity store by mapping table names in the database specified by dbspec to types as specified by the tspeci.

Details and Options

  • If an EntityStore object is included in the list EntityStores[], then the entity types it contains are accessed automatically when Entity is used. Unless permissions are set otherwise, its contents can be modified by assignments of the form entity[property]=value.
  • Data in an EntityStore object can be accessed directly using store[obj,"property"], where obj is an Entity, EntityClass, EntityProperty, or EntityPropertyClass object.
  • In EntityStore[{tspec1,tspec2,}], each of the tspeci can be either "typei" or "typei"datai.
  • In EntityStore["type"data], data is an association that defines entities, properties, and values associated with the specified type.
  • The "Entities" element of data can give an association with properties of entities of the given type: "Entities"-><|"name1"->props1,|>. The propsi give values of properties for the specified entity: <|"propa"->val1a,"propb"->val1b,|>.
  • The special property "Label" can be given for any entity, specifying how it should be displayed.
  • The "Properties" element of data gives information on properties, such as how properties should be displayed and how property values that are not explicitly specified should be computed.
  • Possible entries in the data association for a given type include:
  • "Entities"association giving values of properties for each entity
    "EntityClasses"association giving entities and properties for entity classes
    "Label"label to use in displaying this type
    "LabelPlural"plural form of label to use in displaying this type
    "Properties"association giving information on properties for this type
    "PropertyClasses"association giving property class information for this type
  • The "Properties" entry in data is of the form <|"propa"-><|k1->v1,|>,"propb"->,|>. Possible entries in the association given for each property include:
  • "DefaultFunction"default function to compute the value of this property
    "Label"label to use in displaying this property
  • With the setting "DefaultFunction"->f for a given property, f is applied to an entity to compute the value of that property if it is not specified explicitly in the "Entities" association.
  • Possible entries for each entity class in "EntityClasses" include:
  • "Entities"list of names or predicates specifying entities in the class
    "Label"label to use in displaying this entity class
  • In the association for a particular entity class, "Entities"->{"name1","name2",} gives an explicit list of entities in the entity class. "Entities"->"prop"->pred specifies that the entities in the class are those for which pred gives True when applied to the value of the property prop.
  • Possible entries for each property class in "PropertyClasses" include:
  • "Label"label to use in displaying this property class
    "Properties"names of properties in this property class
  • In the form EntityStore[{"type1"->meta1,"type2"->meta2,},databasespec], the metai can have the following forms:
  • {"col1","col2",}a list of column names to be exposed
    {"prop1""col1",}"coli" is renamed to "propi"
    {,"propi"EntityFunction[],}"propi" is computed from an EntityFunction
    classthe whole type is constructed from a computed class of entities
  • In the form EntityStore[{,"typei"->class,},], class can be any of the heads: EntityClass, FilteredEntityClass, ExtendedEntityClass, SampledEntityClass, SortedEntityClass, AggregatedEntityClass, CombinedEntityClass.
  • In relational-databases-backed entity stores, the structure of the first argument of EntityStore has the form <|"Types"-><|"type1"-><||>,"type2"-><||>,|>|>, where each association on the right-hand side of each "typei" can have the following keys:
  • "Properties"an association defining the properties
    "EntityTypeExtractor"a table name or a computed class
    "CanonicalNameProperties"the properties that form the CanonicalName
  • In relational databases, properties come in three flavors: columns on the original database, computed properties or relations.
  • Column properties are defined with an association containing:
  • "ColumnPrefix"typically, the name of the table
    "ColumnName"the name of the column
  • Computed properties are defined with an association containing:
  • "Function"an EntityFunction defining the property
  • Relations properties are properties that take Entity or EntityClass values referencing types in the EntityStore; they are defined by an association containing:
  • "DestinationEntityType"the entity type referenced by the relation
    "EntityTypeMapping"the mapping between the properties of the incoming and destination entity type
  • "EntityTypeMapping" has the same specification as CombinedEntityClass and can take values of the form:
  • "prop"the origin and destination types have the same values for the property "prop"
    {"prop1","prop2",}the origin and destination types have the same values for all "propi"
    "left""right"the origin type has values for "left" that are the same as the values for "right" in the destination type
    {"left1""right1",}the origin type value of "lefti" is the same as the destination type value for "righti"
    EntityFunction[{left,right},]the value of the relation for the origin entity left is all the destination type entities right for which the entity function evaluates to True
  • In relational-database-backed entity stores, formatting using "Label" properties is disabled to ensure that all calls to EntityValue and EntityList perform a single call to the database.


open allclose all

Basic Examples  (3)

Create an entity store for entities with type "t" named "e1" and "e2", each with properties "p1" and "p2":

Register this entity store in the global list of entity stores:

Now property values for an entity are automatically looked up in the entity store:

Get the list of entities of the specified type:

Find entities whose value of the property "p2" is greater than 100:

Unregister the entity store:

To connect to an external database, construct a RelationalDatabase object:

Construct an EntityStore from the RelationalDatabase object:

Register the EntityStore:

Perform a query:

Unregister the entity store:

Construct a database-backed EntityStore with a subset of the original tables in the database:

Scope  (10)

Basic Uses  (4)

Create an entity store with a computed property "p3" and entity and property classes:

Obtain the computed value:

Look up the members of "ec2":

Get an Association of the value of all properties in "pc1" for one entity:

Access the entity store directly:

Values are not computed:

Access properties of an entity class:

Retrieve the raw data stored for "Entities":

Create an entity store of all integers:

Get the numerical value of an entity:

Compute the factorial of the entity "4":

Invalid entities are rejected:

Change the value of the "Factorial" of the entity "7":

This introduces an entity together with the new value into the registered entity store for "integer":

Other entities do not have an explicit value:

Define an EntityStore containing labeled entities and entity classes:

Normally an EntityClass behaves like the list of entities it represents. Get the "Label" for each entity in the class:

To get the "Label" of the class, access the EntityStore directly:

Put an entity store into the cloud:

Share the cloud object with someone who can then use the entities contained in it:

Database connectivity  (5)

Construct an EntityStore renaming the tables:

Construct an EntityStore with a subset of the columns:

Construct an EntityStore renaming the columns:

Construct an EntityStore with computed types:

Construct an EntityStore with computed properties:

Qualifiers  (1)

Specify "beehive" entities with a "Date"-qualified "Population" property:

Get the latest population for Lisa's beehive:

Get the population for mid-2014:

Use Dated:

This is equivalent:

Get the time series:

The population of all beehives in 2013:

Possible Issues  (2)

In database-backed entity stores, "Label" properties are not used for formatting:

When dealing with external databases, one might encounter a database where the primary key was not set for some tables:

When this happens, EntityStore will emit a message. This means that some functionality involving single entities will be disabled:

But EntityValue will generally keep working:

The only way around this problem is to set the primary key constraint in the external database.

Introduced in 2016
Updated in 2019