# Fact Entities

In a dimensional model, a fact entity represents a database table that contains quantitative information regarding a business process, such as measures and metrics. It is the central entity of a star schema and is surrounded by related dimension entities. This implies that the primary key of each dimension table is also part of the fact table as a foreign key.

### Video

{% embed url="<https://youtu.be/Ug2o6-GE0pE>" %}

### Overview

Let’s assume that we have a sample dimensional model that looks like this:

![01-sample-dimensional-model](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FnuRnoA8jgQbOBNlH64oU%2F01-sample-dimensional-model.PNG?alt=media\&token=62501869-92a2-4115-b418-324c35dd2a2c)

The *Sale* entity in this model represents the fact table and is surrounded by numerous dimension entities in the star schema.

In the next sections of this article, we’ll examine the layout of the *Sale* entity to learn how you can configure facts in Astera Data Stack.

### Layout Builder

To open the properties of the fact entity, right-click on it and select *Properties* from the context menu.

![02-fact-entity-properties](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2F078brn28fk78eJXZUvfM%2F02-fact-entity-properties.PNG?alt=media\&token=08e5967a-cb95-4a8a-a506-48f313fbfa51)

A configuration window will appear. This window provides the same options as it does for a general entity, the only addition being the *Fact Role* column on the *Layout Builder* screen. To learn more about the general entity properties, click [here](https://documentation.astera.com/astera-data-stack-v10/data-model/data-models/general-entity-properties).

On the first screen, you can view and edit some general information regarding the table, including its name, schema, and type.

![03-fact-entity-properties](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2F8LVPM8ssSFl0cnOlafLn%2F03-fact-entity-properties.PNG?alt=media\&token=b2af890c-6604-4321-a54e-da17fa3cd22d)

Click *Next* to proceed to the *Layout Builder* screen.

![04-fact-entity-layout-builder](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FrKYMRNVPTrTXNRsZ2PKH%2F04-fact-entity-layout-builder-1620214105356.PNG?alt=media\&token=583b078a-8224-4d75-b95a-e5fd207baf6a)

### Foreign Keys

In the layout of this fact table, you’ll notice quite a few foreign keys, such as *City\_Key*, *Customer\_Key*, etc.

![05-fact-entity-foreign-keys](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FvmOgd77rD9PnzJV3DU2v%2F05-fact-entity-foreign-keys-1620214122382.png?alt=media\&token=504f068b-0a85-4351-bfe7-d3d828ec0e08)

Each of these foreign keys represents a relationship between this fact table and one of the dimension tables. For example, *City\_Key* represents the primary key of the *City* table, *Customer\_Key* represents the primary key of the *Customer* table, and so on.

### Fact Role

The *Fact Role* column in the layout builder provides a dropdown menu for you to assign the role of *Transaction Date Key* to one of the fields.

![06-fact-roles](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FHAFfA9iFy6dqn4IQKSMs%2F06-fact-roles-1620214233057.PNG?alt=media\&token=f5e31dac-41b3-47ff-9478-b4ffa761f850)

*Transaction Date Key*: A key date field that is coming from the OLTP system.

![07-fact-entity-transaction-date-key](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FCooinwbweJWSwkxnsoLe%2F07-fact-entity-transaction-date-key.png?alt=media\&token=a1425e2d-3856-464e-ac48-78bdb88a99b8)

{% hint style="info" %}
**Note**: Assigning the *Transaction Date Key* fact role to more than one field in a fact entity will cause a verification error in the model.
{% endhint %}

In this case, we’ve assigned the role to the Invoice\_Date\_Key field.

Once you’ve assigned the *Transaction Date Key* role to a field, click *OK*.

This concludes our discussion on fact entities in Astera Data Stack.
