# Build a database

{% hint style="info" %}
User permissions: Administration > Databases and Sync
{% endhint %}

You can build a database from two locations in Phocas: in Designer and on the **Databases** page. The **Databases** page is suitable when you need to build *locked* databases, which you do not have permission to open in Designer.

In both locations, you have the option to build the database immediately or schedule a build to occur later at regular intervals.&#x20;

## Build a database from within Designer

Open the database in Designer and click the **Build** tab.

<div align="left"><figure><img src="https://content.gitbook.com/content/vQCmtGTR7MsjcI62Vdki/blobs/UuL0TXlQIyNATNnyVu04/3273523214.png" alt="" width="429"><figcaption></figcaption></figure></div>

Then select the applicable build method:

* **Build now**: Click **Build**. As shown in the image above, a progress bar displays the status of the build, which turns green when the build is complete, and the **Logs** section underneath displays the details of the build. Click **Open** to exit Designer and view your database in Phocas.&#x20;
* **Schedule a build**: Click **Schedule**, select the [build frequency](#buildadatabase-sleep-pause-builds) and configure the settings as required, then click **Save**. The **Schedule** button turns orange to indicate a schedule has been set.

  <div align="left"><figure><img src="https://content.gitbook.com/content/vQCmtGTR7MsjcI62Vdki/blobs/j7GeluTalRzxKbTNngrO/3272934752.png" alt="" width="494"><figcaption></figcaption></figure></div>

## Build a database via the Databases page <a href="#buildadatabase-buildadatabaseviathedatabasespage" id="buildadatabase-buildadatabaseviathedatabasespage"></a>

Click **Administration** > **Databases**, select the database(s) you want to build, then select the applicable build method:

* **Build now**: Click **Build**. The **Status** column displays the status of the build, which says **Available** (in green) when the build is complete.

  <figure><img src="https://content.gitbook.com/content/vQCmtGTR7MsjcI62Vdki/blobs/zIMrskLunQH4Sx2vZUpy/3272967709.png" alt="" width="758"><figcaption></figcaption></figure>
* **Schedule a build**: Click **More** > **Schedule**, select the [build frequency](#buildadatabase-sleep-pause-builds) and configure the settings as required, then click **Save**. The **Schedule** column displays the schedule frequency.

  <figure><img src="https://content.gitbook.com/content/vQCmtGTR7MsjcI62Vdki/blobs/L8uoqtI7kEuaDIq4iOoD/3272967715.png" alt="" width="509"><figcaption></figcaption></figure>

## Schedule builds <a href="#buildadatabase-sleep-pause-builds" id="buildadatabase-sleep-pause-builds"></a>

The following scheduled build frequencies are available:

* **Based on** [**Sync**](https://docs.phocassoftware.com/administration/sync):&#x20;
  * After sync of **any source** used in this design. The database build runs when that source syncs.
  * After sync of **all selected sources**. This option allows you to choose multiple sources. The database build runs *all* of those sources sync.
  * After sync of **any selected sources**. This option allows you to select specific sync sources. The database build runs when *any* of those sources sync; it doesn't wait for all selected sources to sync.
* **Based on a specified interval**: Hourly, daily (specify timezone and time), weekly (specify timezone, day of week and time), or monthly (specify timezone, first or last day and time).

<div align="left"><figure><img src="https://3446572173-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FvQCmtGTR7MsjcI62Vdki%2Fuploads%2FhXcZoIE9QRvqhYhjhqdZ%2Fimage.png?alt=media&#x26;token=8f48d431-9eb8-47a6-9000-ba3f31003ac0" alt=""><figcaption></figcaption></figure></div>

## Sleep (pause) builds <a href="#buildadatabase-sleep-pause-builds" id="buildadatabase-sleep-pause-builds"></a>

You can sleep database builds during specified hours, such as at night or the weekend. Accessing the database for analysis purposes during sleep times is unaffected - users can analyze the data based on the last available build.

In the image below, despite the Hourly frequency, the database will not build between 8pm and 6am the following day. &#x20;

<div align="left"><figure><img src="https://content.gitbook.com/content/vQCmtGTR7MsjcI62Vdki/blobs/XOGVurfAexBii9hpUDfX/3080391238" alt="" width="170"><figcaption></figcaption></figure></div>

## Cancel a build <a href="#buildadatabase-cancelabuild" id="buildadatabase-cancelabuild"></a>

There might be a situation where you need to cancel a build, for example, if you change your mind about the design after the build has started, you realize you made a mistake, or if the build seems to be *hanging*.

Open the database in Designer, then on the **Build** tab, click **Cancel**. You get a message advising you that the build is being canceled. It might take a while to complete the cancellation process. When the build is canceled, the status bar turns red and displays the progress stage the build was at when it was canceled.

## Set an alert on build failure <a href="#buildadatabase-setanalertonbuildfailure" id="buildadatabase-setanalertonbuildfailure"></a>

To receive an email alert if a build fails, go to your [personal account settings](https://app.gitbook.com/s/7pj8v25BOyqZTdG5mdD1/getting-started/account-settings) and select **Build failures** under **Email notifications**.

## Troubleshooting: Validation errors during build <a href="#buildadatabase-troubleshooting-validationerrorsduringbuild" id="buildadatabase-troubleshooting-validationerrorsduringbuild"></a>

<details>

<summary>Design errors</summary>

If there are errors in your database design, a **Validation Error** window will display after you click **Build**. You need to correct any errors before the build can be queued. Examples of errors include:

* Unmapped dimensions
* Duplicate names of streams, dimensions, properties and measures
* Property titles containing reserved words: "code", "date".
* Expressions in calculated measures containing reserved characters: \\, @, !, ?, \~, |

<img src="https://content.gitbook.com/content/vQCmtGTR7MsjcI62Vdki/blobs/KQA7cJjIZ9B4Vq9Ju5Uu/3087697605" alt="" data-size="original">

</details>

<details>

<summary>Errors in raw data</summary>

If there are errors in your raw data (for example, cells containing unclean data, such as an invalid date format) the database build will exclude the affected data from the build, and list this in the build log as a *Warning*. The excluded data could be a whole line or just a cell.

Click the link under **Detail** to display more information about the error.

<img src="https://content.gitbook.com/content/vQCmtGTR7MsjcI62Vdki/blobs/o5IM2BMddBy5mcGwVJve/3087697611" alt="" data-size="original">

<img src="https://content.gitbook.com/content/vQCmtGTR7MsjcI62Vdki/blobs/dr9Np8VydhLfHjAPOwFL/3087697617" alt="" data-size="original">

</details>

## Open the database

On the **Build** tab in Designer, there's an open **Open** button. However, if you've just created a new database and you click this button now, you'll get a message telling you you're not authorized to view the database. This message displays because this is a new database and an administrator has not yet granted any user access to it. Even though you created and designed the database, you don't automatically have permission to open it and view its contents. Therefore, before you can open a database, you need to complete the next step in the design a database process: [Give users access to the database](https://docs.phocassoftware.com/administration/overview-of-access-to-data).

After you have access to the database, you can use the **Open** button successfully. [Learn about the other ways to open a database](https://app.gitbook.com/s/7pj8v25BOyqZTdG5mdD1/getting-started/databases#databases-waystoopenadatabase).
