# How Do CopyStorm Views Work?

The Salesforce API presents all SObjects (Account,Contact, etc.) as tables to the outside world even though quite a number of SObjects are really subsets/views of other SObjects. The most common example is Salesforce feed tables — there are dozens of feed tables (AccountFeed, ContactFeed, etc.) that are simply views of the table that contains all feeds: FeedItem.

* The AccountFeed table is really a view on the base table FeedItem.
  * SELECT \* FROM FeedItem WHERE parentId IS an Account Record.

There are also cases where the Salesforce API does not support a direct query on an SObject but the SObject can be constructed from other SObjects.

* The ActivityHistory table is a union of the Event and Task SObjects but cannot be queried directly using SOQL.

There are other issues of this kind, but lets get to the important part. When Database Views are enabled in CopyStorm, then CopyStorm will use views in the target database rather than copying a table. This can lead to much faster backups for each table that can be represented as a view.

## How to Enable Database Views

Database Views are enabled by default in CopyStorm and when enabled:

* If a Salesforce table does not exist in the target database and can be represented as a view, then CopyStorm will create it as a view.
* If a Salesforce table already exists in the target database, then CopyStorm will not re-create it as a view but will continue to treat it as a table.

If Database Views are disabled in CopyStorm:

* Database Views will not be created for new tables.
* If a Database View already exists in the target database, then CopyStorm will not change it.

The toggle that enables/disables Database Views is found in the [Database Schema](https://learn.capstorm.com/reference/configuration-tab/database-schema) configuration section of the CopyStorm Configuration tab.

![](https://4057376488-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsbSqfKw3vSfr8qwXao4j%2Fuploads%2Fgit-blob-83adf2acac938e6c4734c01dac424e11b5b90f57%2F2c6b4fd4-Enable-Views.png?alt=media)

## Implementation Details

This section is for anyone wanting to know exactly how the logic for determining whether a Database View should be used works.

### **Case 1: Use Database View = TRUE**

![](https://4057376488-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsbSqfKw3vSfr8qwXao4j%2Fuploads%2Fgit-blob-5b4873ed343eec7aa0c17dfb2c29e25e39f2eda6%2F15ffafde-DatabaseViewsTrue.png?alt=media)

### Case 2: Use Database Views = FALSE

![](https://4057376488-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsbSqfKw3vSfr8qwXao4j%2Fuploads%2Fgit-blob-d0166c6abc800a1f5a507ebce446ae88d8efc45a%2F719fbd9e-DatabaseViewsFalse.png?alt=media)


---

# Agent Instructions: 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:

```
GET https://learn.capstorm.com/frequently-asked-questions/how-does-copystorm-work/how-do-copystorm-views-work.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
