> For the complete documentation index, see [llms.txt](https://help.sdocs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.sdocs.com/developer-hub/s-docs-system-architecture/s-docs-entity-relationship-diagram.md).

# S-Docs Entity-Relationship Diagram

```mermaid
erDiagram
    GENERIC_BASE_OBJECT {
      id Id PK
      string Name
      string ObjectApiName
    }

    SDOC__SDTemplate__c {
      id Id PK
      string SDOC__Base_Object__c
      boolean SDOC__Create_File__c
      boolean SDOC__Create_Attachment__c
    }

    SDOC__SDAction__c {
      id Id PK
      id SDOC__Template__c FK
      string SDOC__Apex_Class__c
      string SDOC__Description__c
    }

    SDOC__SDoc__c {
      id Id PK
      id SDOC__SDTemplate__c FK
      id SDOC__SDJob__c FK
      string SDOC__ObjectID__c
      string SDOC__ObjectType__c
      string SDOC__File_ID__c
      string SDOC__File_Version_ID__c
      string SDOC__Status__c
    }

    SDOC__SDRelationship__c {
      id Id PK
      id SDOC__SDoc__c FK
      id SDOC__Account__c FK
      id SDOC__Case__c FK
      id SDOC__Contact__c FK
      id SDOC__Opportunity__c FK
      id SDOC__Lead__c FK
    }

    ContentDocument {
      id Id PK
      string Title
      id LatestPublishedVersionId FK
      string FileType
    }

    ContentVersion {
      id Id PK
      id ContentDocumentId FK
      string Title
      string VersionNumber
      boolean IsLatest
    }

    ContentDocumentLink {
      id Id PK
      id ContentDocumentId FK
      id LinkedEntityId FK
      string ShareType
      string Visibility
    }

    SDOC__SDTemplate__c ||--o{ SDOC__SDoc__c : "Template drives generation"
    SDOC__SDTemplate__c ||--o{ SDOC__SDAction__c : "Template actions"
    SDOC__SDoc__c ||--o{ SDOC__SDRelationship__c : "Junction rows per related record"
    GENERIC_BASE_OBJECT ||--o{ SDOC__SDRelationship__c : "Related via object-specific lookup"
    ContentDocument ||--o{ ContentVersion : "Has versions"
    ContentDocument ||--o{ ContentDocumentLink : "Linked to records"
    GENERIC_BASE_OBJECT ||--o{ ContentDocumentLink : "LinkedEntityId"
    SDOC__SDoc__c o|..o{ ContentDocument : "Referenced by SDOC__File_ID__c (string id)"
```

### Relationship Notes

* `SDOC__SDTemplate__c` is the design-time template used to produce `SDOC__SDoc__c` records.
* `SDOC__SDAction__c` rows are child action definitions linked to `SDOC__SDTemplate__c` through `SDOC__Template__c`.
* `SDOC__SDRelationship__c` is a junction from one `SDOC__SDoc__c` to one or more business records (represented here as `GENERIC_BASE_OBJECT`).
* `ContentDocument` and `ContentVersion` represent Salesforce Files storage.
* `ContentDocumentLink.LinkedEntityId` links the file to records, typically the business record and sometimes additional records.
* `SDOC__SDoc__c.SDOC__File_ID__c` and `SDOC__File_Version_ID__c` are string references to file artifacts, not hard lookup relationships.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://help.sdocs.com/developer-hub/s-docs-system-architecture/s-docs-entity-relationship-diagram.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
