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

# Forward Engineering

Forward Engineering is the process of generating a database schema from a physical model. It enables the synchronization of the data model with the database when physical changes have been made to the data model, such as adding, removing, or changing entities, fields, indexes, physical names, and relationships. It also employs all the changes that are made in the data model while restructuring it. While it executes physical changes, logical changes are not reflected in forward engineering.

### Video

{% embed url="<https://youtu.be/_1eVZjXn9G0>" %}

### How to Forward Engineer a Data Model

To forward engineer a data model, click on the forward engineering icon in the toolbar of the data model designer. By default, this option generates a DDL script when selected.

![01-toolbar-forward-engineer-option](/files/R3di964CSEepYOHrReWb)

When you click the arrow next to the *Forward Engineer* icon, a drop-down menu appears, that shows the four options to forward engineer the data model.

These options are:

1. Create Database Objects
2. Sync Database With Model
3. Generate Full Create Script
4. Generate Drop/Create Script For Diff

<img src="/files/NgYozYjmYvnMytfvBnj5" alt="02-forward-engineer-dropdown" width="395">

Let’s consider the following data model to explore each of these forward engineering options one by one.

![03-data-model](/files/h8fHnlZJafCrX22oSbk0)

This data model represents a simple star schema, with one *Fact* and four *Dimensions*.

#### **Create Database Objects**

The *Create Database Objects* option generates an SQL Script that creates all the objects defined in the data model on the specified database. This includes tables, views, indexes, and other schema components. It then automatically executes it on the specified database.

1. Specify the database connection where you want to execute the script. To do that, click on the *Change Database Connection Info* icon in the toolbar. Alternatively, press Shift+Alt+C to open the *Database Connection* window.

![04-database-connection-icon](/files/cLaDtVLBrNqv9nUIPTQO)

Specify the database connection information and click *OK*.

<img src="/files/avypMKwkNaLo2cUpPdBh" alt="05-database-connection-window" width="554">

2. Select the *Create Database Objects* option from the *Forward Engineer* option dropdown menu. Alternatively, press Shift+Alt+F1.

<img src="/files/4N5z0EFVgM5oT7JQlzOJ" alt="06-generate-database-objects" width="398">

3. The *Apply Scripts* window shows all the operations that will be applied to the database once the script is executed. It gives the summary of the following:
   1. Operation
   2. Table Name
   3. Type

View all the changes and click *Execute*.

<img src="/files/UXnfNjEDcb0jg3B1hiYl" alt="07-apply-script-window" width="479">

The script will be executed, and the operations will be performed on the specified database. The progress can be seen in the *Job Progress* window.

![08-job-progress-window](/files/PyzOpcFWR9UiY6LUtMuP)

#### **Sync Database With Model**

The *Sync Database With Model* option generates and executes a script that updates the target database schema to match the current data model. It automatically identifies and applies any changes such as added or modified tables, columns, or relationships, needed to synchronize the database.

<figure><img src="/files/6jnvgO2OF0vJcQCigpEL" alt="" width="396"><figcaption></figcaption></figure>

#### **Sync Database With Model**

A Diff Script is a SQL script that reflects any differences between the data model and the corresponding database. The *Sync Database With Model* option generates a Diff Script for all the differences between the data model and the corresponding database and automatically executes it on the specified database.

1. Specify the database connection where you want to execute the script.
2. Select the *Sync Database With Model* option from the *Forward Engineer* option dropdown menu. Alternatively, press Shift+Alt+F2.

<img src="/files/6jnvgO2OF0vJcQCigpEL" alt="09-sync-database-with-model" width="396">

If you select *Apply Diff Script* and there are no differences between the data model and the corresponding database, a message that ‘No changes were detected’ will be shown.

<img src="/files/TOUCitwjrqFN4SB2nGfb" alt="10-no-changes-detected" width="380">

Let’s add a new Dimension to the data model and link it to the Fact with a non-identifying relationship. The data model now looks like this.

![11-changed-data-model](/files/FNxwkKtvFMaND11QXtBB)

Select the *Sync Database With Model* option after making the changes specified above.

3. The *Apply Scripts* window shows all the changes that were made to the data model. In this case, it shows that a new dimension has been added. View all the changes and click *Execute*.

<img src="/files/71YoYmjwkVAS3vEj9rLN" alt="12-apply-script-window-entity-added" width="474">

The script will be executed, and the changes will be made to the specified database. The results of the transaction can be seen in the *Output* window.

![13-output-apply-diff-script](/files/ajV6HwG6FVgNqLPrxpaz)

#### **Generate Full Create Script**

The *Generate Full Create Script* option generates an SQL Script for the entire data model schema. It does not execute the script automatically. However, the generated script can be executed in the database.

To generate a DDL script for the data model, select *Generate Full Create Script* option from the *Forward Engineer* option dropdown menu. Alternatively, press Shift+Alt+F3.

<img src="/files/rUv7SruMJIxZ7iZGoaTQ" alt="14-generate-full-create-script" width="392">

In the *Save* window that shows up, navigate to the desired directory, provide a name for the DDL script, and select *Save*.

![15-save-ddl-script](/files/sOfk9Q7UBgbpqEU0pB0o)

The DDL script has been generated and saved. You can execute this script in the database server if required.

#### **4.** **Generate Drop/Create Script for Diff**

The *Generate Diff Script* option generates a Diff Script for all the differences between the the data model and the corresponding database. It does not execute the script automatically. However, the generated script can be executed in the database.

To generate a Diff Script for the data model, select *Generate Diff Script* option from the *Forward Engineer* option dropdown menu. Alternatively, press Shift+Alt+F4.

<img src="/files/1qmn0q8eyklt2XKi4SBz" alt="16-generate-drop-create-script-for-diff" width="403">

In the *Save* window that shows up, navigate to the desired directory, provide a name for the Diff script, and select *Save*.

![17-save-diff-script](/files/r91PTr2GJWBaubqZCTDw)

The Diff script has been generated and saved. You can execute this script in the database if required.

### Forward Engineering Selected Entities

Each of the four forward engineering options can also be applied to a single entity or a set of entities selected. Select the entity or the set of entities that you want to forward engineer and select one of the four forward engineering options. The script will be generated and/or applied only for the selected entities.

![18-apply-script-to-selected-entities](/files/Tnniek1XLMVFftkkjT49)

This concludes our discussion on forward engineering a data model in Astera Data Stack.


---

# 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, and the optional `goal` query parameter:

```
GET https://documentation.astera.com/data-model/data-models/forward-engineering.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
