# Verifying a Data Model

A data model needs to be checked for any possible errors or warnings before it can be forward engineered to a target database or deployed to the server for usage. In Astera Data Stack, you can use the verification option to perform this verification.

### Video

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

### How to Verify a Data Model

To verify a data model, click on the *Start Verification* icon in the toolbar.

![01-start-verification-icon](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2Fj73QxZLuCuK5SfFvIdgq%2F01-start-verification-icon.PNG?alt=media\&token=a2ceaf88-f6f2-4eb8-9743-e2ef4e867a18)

If the model is erroneous, the *Verify* window will display a list of error and warning messages. If not, it will indicate that the model has been successfully verified and contains no errors. Let’s verify the following model as an example.

![02-sample-data-model](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FW2y15zQntmLn4yOcJDih%2F02-sample-data-model.PNG?alt=media\&token=1adce6f1-4263-46fd-938b-e155f0ed09c4)

This particular model contains no errors or warnings. Upon clicking the *Start Verification* option, the *Verify* window will show that it has been verified successfully.

![03-verification-successful](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FfHy8uPdzGvOk0LQSRH12%2F03-verification-successful.PNG?alt=media\&token=af2e078d-b417-41be-948c-ec8e9d36da63)

### Types of Verification

When you expand the *Start Verification* option, you’ll see that there are two types of verification.

![04-types-of-verification](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FUkQ8bUwGlgOO07Jrfs6B%2F04-types-of-verification.PNG?alt=media\&token=2ff4d80e-0226-446d-88ad-88b15efd11bd)

#### Verify for Read and Write Deployment

This is the default option for the *Start Verification* button.

*Read and Write Deployment* refers to publishing the data model to the server for usage in ETL processes or for data visualization through a built-in OData service. For more information on deployment in Astera Data Stack, click [here](https://documentation.astera.com/astera-data-stack-v10/data-model/deployment-and-usage/deploying-a-data-model).

When the *Verify for Read and Write Deployment* option is selected, the *Verify* window shows whether a model is ready to be deployed. In case there are any errors in the model, you’ll have to fix them before you can deploy it.

#### Verify for Forward Engineer

*Forward Engineer* refers to mirroring any changes you’ve made to a data model into a target database.

When the *Verify for Forward Engineer* option is selected, the *Verify* window shows whether the changes made to model are ready to be reflected into the database. In case there are any errors in the model, you’ll have to fix them before you can forward engineer it.

### Common Verification Errors

Here are some common errors that you may encounter when verifying a data model:

#### Case 1: No Primary Key

In this case, we have a data model that contains one entity named *Orders*.

![05-verification-case1-model](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2Fbe1F6DPeP4IpiOA4sOTd%2F05-verification-case1-model.PNG?alt=media\&token=1b40fe6f-7333-4caf-bef3-b3a0157e8581)

This entity does not contain a primary key, as indicated by its layout.

![06-entity-layout-no-primary-key](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2F1IFgd7yaB6NWS7kJAWYg%2F06-entity-layout-no-primary-key.PNG?alt=media\&token=98dc4dac-0f99-4665-abde-93d86d762bfc)

On verifying for read and write deployment, the *Verify* window will display the following errors:

![07-case1-verification-errors](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FBMOjEIkSBIxmKS5AXuFx%2F07-case1-verification-errors.PNG?alt=media\&token=2a181517-10cf-46be-a7ea-5f748092b3b6)

The first error indicates that there is no primary key field in the *Orders* entity.

The second error indicates that the field *OrderID* in the entity layout is the primary key within the database table but not within the data model.

**Solution**: Go to the entity layout and select the *Primary Key* checkbox for the *OrderID* field.

![08-case1-verification-primary-key](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FeGozRQp3beUQ9FqRHqIi%2F08-case1-verification-primary-key.PNG?alt=media\&token=64f87dd0-f7ed-4650-914b-1d9cc0355bb1)

Click *OK*. The model can now be verified successfully.

#### Case 2: Data Type Mismatch

In this case, we have a data model that contains two entities, *Shippers* and *Orders*, that are related to each other.

![09-case2-model](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FMYnY1Av826J0G0npq4pJ%2F09-case2-model.PNG?alt=media\&token=6f52b5ea-8b2e-445d-a202-c0b3c746da57)

Here is the layout of the *Orders* entity.

![10-orders-entity-layout](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FbkUF7Xln32gwdn244p1T%2F10-orders-entity-layout.PNG?alt=media\&token=0a00bb10-44d3-49d5-b9c8-784bf72b6bc9)

You’ll notice that the data type for the *ShipVia* field is *Decimal* and the *db type* is *NUMERIC*. In actuality, these should be *Integer* and *INT*, respectively.

On verifying for read and write deployment, the *Verify* window will display the following errors:

![11-case2-verification-errors](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FbrFGseW5JwiwDmaNa6ca%2F11-case2-verification-errors.PNG?alt=media\&token=310c2358-2f6a-4b82-8ee7-a093543c07ff)

The first two errors indicate that the data type for the *ShipVia* field in the Orders entity does not match with its data type in the database.

The third error indicates that the data type for *ShipVia* does not match with its corresponding field in the *Shippers* entity, which is the parent entity in this case.

**Solution**: Go to the layout of the *Orders* entity and change the data type of *ShipVia* to *Integer* and change its db type to *INT*. You can do so using the dropdown menus in the *Data Type* and *Db Type* columns.

![12-case2-verification-data-type](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FbZSbPGFnovrHFt6mN3QG%2F12-case2-verification-data-type.PNG?alt=media\&token=2f10e1f7-9c95-47ed-8421-578bd11dc2de)

Click *OK*. The model can now be verified successfully.

#### Case 3: More Than One Clustered Index

In this case, we have a data model that contains one entity named *Orders*.

![13-case3-model](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FoJugmbdaiR50pU9CXJxE%2F13-case3-model.PNG?alt=media\&token=12b422a8-1dc1-4964-a528-bbced0d41052)

This entity contains two clustered indexes. However, you cannot have more than one clustered index within an entity.

![13-verification-clustered-indexes](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FtQ7oOiHNrHmg70HeIdfc%2F13-verification-clustered-indexes.PNG?alt=media\&token=0449d5ce-0629-4ee3-b384-65c7a42254e9)

On verifying for forward engineering, the *Verify* window will display the following error:

![14-case3-verification-error](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2F8lnahNERfGYeoEe3Tt7Q%2F14-case3-verification-error.PNG?alt=media\&token=7e665793-986b-482e-a08d-3555a181d33c)

The error simply states that you cannot have more than one clustered index in the entity.

**Solution**: Go to the *Data Model Entity Indexes* screen and delete one of the clustered indexes using the *Delete Index* icon.

![15-case3-verification-delete-index](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FvJKAeiEhyjHq4IX03gRg%2F15-case3-verification-delete-index.PNG?alt=media\&token=d056efff-8eb7-4027-bfac-294bb90a4d6c)

![16-case3-verification-index](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FS3uciAD34o0DJvf60ukD%2F16-case3-verification-index.PNG?alt=media\&token=c17d69e0-8bcf-4fa3-a225-f748793fd5ab)

Click *OK*. The model can now be verified successfully.

This concludes our discussion on verifying a data model.S
