> For the complete documentation index, see [llms.txt](https://doc.telosys.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.telosys.org/models/model-creation.md).

# Model creation

There are 2 ways to create a Telosys model :&#x20;

* **creation from scratch** \
  to create an empty model in which you can then create the entities you need&#x20;
* **creation from an existing relational database** \
  to create a model from a database with an entity for each table

### Creating a model from scratch&#x20;

**Step #1 - Create a void model**

To create a model from scratch use the "**nm**" (New Model) command.

Syntaxe:

**`nm  <model-name>`**&#x20;

&#x20;     \<model-name>   -> the name of the new model to create

This command creates a new model with the given name.

This model is void, it does not contain any entity.

**Step #2 - Add entities to the model**

To add entities, use the "**ne**" (New Entity) command.

Syntaxe:

**`ne  <entity-name>`**&#x20;

This command creates a new entity with the given name -> a file "**entity-name.entity**"

You can now edit the ".entity" files of the model with any editor or IDE to define the attributes and links.

You can also "copy/paste" certain files if you have similarities between entities.

### Creating a model from a database

If you have a relational database with tables and links based on foreign keys then you have a relationship model.  Telosys is able to build its own model from this  database model.

To do so, you just have to define your database -> see the page "[Project databases](/project-databases.md)"

Once you have define the database and check the configuration with "cdb" command you can create a Telosys model from this database with the "**nm**" command.

Syntaxe:

**`nm  <model-name>  <database-id>`**

&#x20;     \<model-name>   -> the name of the new model to create

&#x20;     \<database-id>   -> the id of a database defined in "databases.yaml"

An entity will be created for each table matching the patterns defined in the database configuration.

You can check the entities created and if necessary you can customize them by editing the ".entity" files.&#x20;


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.telosys.org/models/model-creation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
