ExtendedEntityClass[class,"name"f]
represents an entity class derived from class by adding a new computed property "name" whose value for each entity is obtained by applying the entity function f.
ExtendedEntityClass[class,{"name1"f1,"name2"f2,…}]
adds the properties namei defined by the functions fi.
ExtendedEntityClass
ExtendedEntityClass[class,"name"f]
represents an entity class derived from class by adding a new computed property "name" whose value for each entity is obtained by applying the entity function f.
ExtendedEntityClass[class,{"name1"f1,"name2"f2,…}]
adds the properties namei defined by the functions fi.
Details
- In ExtendedEntityClass[class,"name"->f], the function f must be an EntityFunction object.
- ExtendedEntityClass works with any EntityStore object, whether defined explicitly or based on a RelationalDatabase object.
- ExtendedEntityClass[class,"new"->f] effectively represents a virtual database table derived from class, with a new column named new added, with values f[entityi] for each entity entityi.
- For an extended entity class ExtendedEntityClass[class,"new"->f], the full name of the new property added is EntityProperty[ExtendedEntityClass[class,"new"f],"new"].
- ExtendedEntityClass[class,"new"->f] adds a new computed property even if class already has a property whose name is "new". In this case, however, the new computed property must be referred to using the full name EntityProperty[ExtendedEntityClass[class,"new"f],"new"].
- If the name of a new property does not conflict with the names of any existing properties, then EntityValue[class,"new"] can be used to get values of the new property.
Examples
open all close allBasic Examples (3)
Use ExtendedEntityClass to add a computed property to a class of entities:
ExtendedEntityClass[EntityClass["Country", "G8"], "AdultFraction" -> EntityFunction[c, c["AdultPopulation"] / c["Population"]]]["AdultFraction"]ExtendedEntityClass[EntityClass["Element", "Metal"], "AtomicWeight" -> EntityProperty["Element", "AtomicMass"]]["AtomicWeight"]When used with relational-database-backed entities, ExtendedEntityClass is equivalent to adding an expression in the SELECT statement:
EntityRegister[EntityStore[RelationalDatabase[FindFile["ExampleData/ecommerce-database.sqlite"]]]]ExtendedEntityClass["employees", "fullName" -> EntityFunction[x, x["firstName"] <> " " <> x["lastName"]]]["fullName"]Scope (1)
Add multiple properties at the same time:
ExtendedEntityClass[EntityClass["Language", "EuropeanUnionLanguages"], {"WikipediArticlesPerCapita" -> EntityFunction[l, l[EntityProperty["Language", "WikipediaArticleCount"]] / l[EntityProperty["Language", "TotalSpeakers"]]], "YesNo" -> EntityFunction[l, Lookup[l[EntityProperty["Language", "BasicCommunicationWords"]], {Entity["Word", "yes"], Entity["Word", "no"]}]]}][{"WikipediArticlesPerCapita", "YesNo"}]Applications (1)
ExtendedEntityClass can be used to avoid repeating code:
SortedEntityClass[
"Planet",
EntityFunction[e, e[EntityProperty["Planet", "Diameter"]] / e[EntityProperty["Planet", "DistanceFromSun"]]]
][
EntityFunction[e, e[EntityProperty["Planet", "Diameter"]] / e[EntityProperty["Planet", "DistanceFromSun"]]]
]SortedEntityClass[
ExtendedEntityClass[
"Planet",
"ratio" -> EntityFunction[e, e[EntityProperty["Planet", "Diameter"]] / e[EntityProperty["Planet", "DistanceFromSun"]]]
],
"ratio"
]["ratio"]Possible Issues (1)
When dealing with SQL-backed entities, it is not possible to extend an entity class with nonscalar values:
EntityRegister[EntityStore[RelationalDatabase[FindFile["ExampleData/ecommerce-database.sqlite"]]]]ExtendedEntityClass["customers", "PaymentsAmount" -> EntityFunction[c, c["payments"]["amount"]]]["PaymentsAmount"]Neat Examples (1)
ExtendedEntityClass[EntityClass["Language", "EuropeanUnionLanguages"], "FlagColors" -> EntityFunction[l, Nearest[Normal@KeySelect[ColorQ]@KeyMap[Interpreter["StructuredColor"] @* CanonicalName, l[EntityProperty["Language", "ColorNames"]]], DominantColors[l[EntityProperty["Language", "LargestCountry"]][EntityProperty["Country", "Flag"]]]][[All, 1, 1, "Translation"]]]]["FlagColors", "EntityAssociation"]Tech Notes
History
Text
Wolfram Research (2019), ExtendedEntityClass, Wolfram Language function, https://reference.wolfram.com/language/ref/ExtendedEntityClass.html.
CMS
Wolfram Language. 2019. "ExtendedEntityClass." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ExtendedEntityClass.html.
APA
Wolfram Language. (2019). ExtendedEntityClass. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ExtendedEntityClass.html
BibTeX
@misc{reference.wolfram_2026_extendedentityclass, author="Wolfram Research", title="{ExtendedEntityClass}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/ExtendedEntityClass.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_extendedentityclass, organization={Wolfram Research}, title={ExtendedEntityClass}, year={2019}, url={https://reference.wolfram.com/language/ref/ExtendedEntityClass.html}, note=[Accessed: 12-June-2026]}