-
Notifications
You must be signed in to change notification settings - Fork 3
Syntax
Any model in ERtext is divided into three blocks, which behave like containers. Each block must have a ;
to its end, indicating that its declaration is complete.
In its header there is still the optional Generate command that indicates which artifacts should be generated. If the command is omitted, all artifacts will be generated at once (default behavior).
Its syntax has the following structure: Generate <statement>;
Available options are
All
,Diagram
,LogicalSchema
,MySQL
, andPostgreSQL
.
e.g. Generate PostgreSQL;
The first block covers the model domain. This container later serves as the name of the conceptual diagram, logical model and SQL models.
Its syntax has the following structure: Domain <Name>;
e.g. Domain TemplateModel;
The second block covers the Entities of the model. This block starts with the keyword Entities
followed by a {
.
Its syntax has the following structure:
Entities {
<EntityName> {
<attributeName> <attributeType> isIdentifier,
<attributeName> <attributeType> ...
}
...
};
By convention, it is recommended that entity names begin with uppercase letters, and attribute names with lowercase letters.
An entity is defined by a name followed by a {
. An entity can have one or many attributes. An attribute is defined by a name, and must have an associated datatype (int
, double
, money
, string
, boolean
, datetime
, file
). The attributes (fields) of an entity are separated by a comma from each other. An entity must at the end have a }
to indicate that it has been fully declared. You must NOT put ;
between entity declarations.
One entity may still be a specialization of another. To do this, simply indicate with the keyword is
followed by the generalization type (is total/disjoint
, is total/overlapped
, is partial/disjoint
, is partial/overlapped
).
- An example of an Entity block with 5 modeled entities is as follows:
Entities {
EntA {
att1 int isIdentifier,
att2 file
}
EntB is total/disjoint EntA {
att3 string,
att4 datetime
}
EntC {
att5 int isIdentifier,
att6 string
}
EntD {
att7 int isIdentifier,
att8 money
}
EntE {
att9 int isIdentifier
}
};
Finally, the third block defines the relationships between the modeled entities. This block starts with the keyword Relationships
followed by a {
.
A relationship has a name, and is followed by an opening of [
. At this point, the name of the first entity in the relationship must be indicated, followed by the cardinality, the reserved word relates
and the cardinality and name of the other related entity. The syntax is as follows:
[EntX (0:1) relates (1:N) EntY]
NOTE: The form of reading happens in the same way that it occurs in a diagram.
e.g. ONE instance ofEntX relates
to ONE OR MANY instances ofEntY
. ONE instance ofEntY relates
to ZERO OR ONE instance ofEntX
.
It is still possible to set attributes for a relation by opening { }
's. The definition happens in the same way as for entities.
- An example of a relationship block with 4 modeled relations is given as follows:
Relationships {
R1 [EntA (1:N) relates (1:N) EntA] {attr1 int}
R2 [EntC (1:1) relates (1:1) EntD]
R3 [EntD (0:N) relates (1:N) EntC]
R4 [R3 (1:1) relates (1:N) EntE] //This is a ternary relationship
};
The DSL also supports single-line comments as follows:
//This is a single commented line
Likewise, it also supports block comments, used to comment out multiple lines of code at the same time. We use /* and */ to insert comments in this style, as follows:
/*
* This is a block comment
*/
@TODO
Main developer: Jonnathan Riquelmo
Project members: Maicon Bernardino (Advisor) and Fábio Basso (Co-advisor)
Research group: Laboratory of Empirical Studies in Software Engineering (LESSE)™
Federal University of Pampa (UNIPAMPA) - Campus Alegrete, RS