Schema Name and Type Key
The schema name specifies the name of the table created in a database where records of a persistable Type are stored (recall that persistable Type data are stored in tables in a database). Developers are able to customize these table names by specifying a schema name.
In Version 8 of the C3 Agentic AI Platform, schema name and schema suffix are no longer required. The current best practice is to not specify schema names. The type key is still required, assuming you want to differentiate between instances of different Types that extend some Type.
Use the keyword schema name along with a valid schema name to persist instances of the Type to the desired table. A valid schema name has the following specifications:
- Uppercase abbreviations using the 26 alphabet letters and optional underscores.
- Under 30 characters for table/column names.
In the example below, a table with the name BULB is created and stores LightBulb instances.
/**
* A single light bulb
*/
extendable entity type LightBulb schema name "BULB" {
}Example
Field level schema names are also required for Collection (Maps, Arrays, Sets) fields without foreign-key collection notation.
- Regular collection fields (not foreign-key collection fields)
- (Stored) Calculated collection fields
/**
* A smartbulb capable of storing fixture history and an array of fixtures
*/
entity type SmartBulb extends LightBulb type key "SMARTBULB" {
fixtureHistory: [SmartBulbToFixtureRelation](from)
// This data will be stored in a table named "SMARTBULB_FIX"
fixtures: [Fixture]stored calc "fixtureHistory.to" schema name "FIX"
}The fixtures field in the example above can store an array of Fixture Types using the schema name FIX. This collection can be stored in a table named SMARTBULB_FIX since the string FIX can be appended with an underscore to the schema name of the parent Type, SmartBulb (see the above example).
For nested included collection fields, the physical name of the column concatenates all schema names with underscores between them. This could reach the 30-character limit for table and column names. It is possible to use schema suffix instead of schema name to create unique field-level schema names and avoid exceeding the character limit. Using schema suffix means no underscores can be used during concatenation. It is best practice to use short schema names.
fixtures: [Fixture]stored calc "fixtureHistory.to" schema suffix "_FIX"Use type key in place of schema name when extending a persistable Type in a Type definition. Extension Types are stored in the same table as the extended Type, so there is no need to define a new table name. The type key value is a suffix that identifies rows corresponding to the subtype in the table:
/**
* A bulb capable of storing power consumption, light output, location, and more.
*/
@db(order='descending(start), descending(end)')
entity type SmartBulb extends LightBulb type key "SMARTBULB" {
// ...
}