Skip to content
JonnathanRiquelmo edited this page Apr 28, 2022 · 2 revisions

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.


Generate Command

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, and PostgreSQL.

e.g. Generate PostgreSQL;


Domain

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;


Entities

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
	}
};

Relationships

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 of EntX relates to ONE OR MANY instances of EntY. ONE instance of EntY relates to ZERO OR ONE instance of EntX.

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
};

Comment Annotation

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
*/

Ocurrence Diagram Annotation

@TODO