> 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
