# Reverse Engineering an Existing Database

Reverse engineering is the process of constructing a data model from an existing database. When you reverse engineer a database in Astera Data Stack, it creates a logical structure that incorporates the tables in the database, and the relationships between them. In essence, It synchronizes the data model with the database and its entities.

### Video

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

### Overview

There are two ways to reverse engineer a database in Astera Data Stack. One is from the toolbar on the data model designer and the other one is from the main menu.

Let’s explore each, one by one.

### Reverse Engineer: Using the Tool Bar Icon

On the toolbar of the data model designer, there is an icon for reverse engineering.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FRmKr8hzdsA4kKYNcMGl1%2F01-Reverse-Engineer-Tool-Bar.png?alt=media\&token=08105a50-f3ba-4657-b96f-845abf369f84)

### Reverse Engineer: Using the Main Menu

On the main menu bar of Astera Data Stack, there is an option for *Data Model > Reverse Engineer*.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FWJrvGnYv7QVvTy3e1CsC%2F02-Reverse-Engineer-Main-Menu.png?alt=media\&token=c0331f3f-b393-45ee-a398-04539ede49d9)

Once you select either of these two options, a *Reverse Engineering* wizard will open on the screen.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FWuEc7moKdXb2kWnPovfi%2F03-Reverse-Engineering-Wizard.png?alt=media\&token=1f93f3b9-c739-4c5d-8e4b-6e3a0e30a8d7)

In case you haven’t established a database connection earlier, specify a connection from within the *Reverse Engineering* wizard.

Click on the ellipses in front of the *Database Connection* option. A *Database Connection* screen will open.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2F1MhEtSY1LnmUNtBafpy1%2F04-Database-Connection-Ellipses.png?alt=media\&token=a0fa2c0d-ce12-4dd5-9ed1-4759b3203adc)

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FpX5lo8JSbr9tgERcyBoI%2F05-Database-Connection-Wizard.png?alt=media\&token=a7d5d7b4-0f89-40e0-b765-bcb577f7ddfb)

On this screen, select the data provider for the database and fill in the required credentials. Once done, click *OK*.

There is a list of data providers that Astera Data Stack supports.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FfRMekmO5Td4NjnXkvvDR%2F06-Data-Provider-Database.png?alt=media\&token=c7766297-580d-44ca-8927-5e1c40bbf8c4)

{% hint style="info" %}
**Note**: In this case, we will select SQL Server as our database provider.
{% endhint %}

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FN7vFoMoNcAtIKhOXBnkc%2F07-Database-Connection-Credentials.png?alt=media\&token=f407fc47-548c-4df8-9948-51b979b3bb59)

Now, all the tables in the database have been listed as *Entities* on the Reverse Engineering wizard.

The following information is available for each entity:

* Exist? - Identifies if the entity already exists in the model
* Type - Specifies the type of the entity in the database (Example: Table)
* Schema - Represents the schema that the entity belongs to in the database
* Name - Name of the entity in the database

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2F0O8TBpZlGRu1T43X1sdy%2F08-Database-Entities.png?alt=media\&token=7754e5d6-b0ac-40d2-afd1-fefa6bfa0174)

Select the entities that you want to reverse engineer in the data model.

{% hint style="info" %}
**Note**: In this case, we are selecting all the listed entities.
{% endhint %}

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2F96jZnxZmT29xPCDvqk0a%2F09-Selecting-Entities.png?alt=media\&token=2a271fcf-868c-4431-b115-5a21a908634c)

On the *Reverse Engineering* wizard, there is a *Search* option that can be used when there are numerous listed entities and specific entities are to be reverse engineered from the database.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FwDuSBIDPpAB6zybY1ilp%2F10-Search-Entities.png?alt=media\&token=f0605b1a-e603-4973-b86b-f6d88882978d)

There is also an option to filter out listed entities for each information type provided. Upon selecting the filter, it would open a new wizard where you can specify filter options.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FdymJcTNBnFlngCaPUx2v%2F11-Filter-Entities.png?alt=media\&token=242d1381-385f-4215-877f-2d75facfedcb)

Once you’ve selected the entities for reverse engineering, click *OK*.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2F0ttAyLwXSUphV5wm3a9Y%2F12-Close-Reverse-Engineering.png?alt=media\&token=967c8b83-566a-496e-b808-b6bdf2f25116)

When the process is complete, the selected entities from the database will appear on the data model designer.

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FcbEGOBL5VICgEAFLlD8q%2F13-Reverse-Engineered-Database.png?alt=media\&token=f8e2a496-463a-43a0-bd15-a5fa1ab7c955)

This concludes our discussion on reverse engineering an existing database in Astera Data Stack.

<br>
