> For the complete documentation index, see [llms.txt](https://docs.snapfix.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.snapfix.com/engineering-reference/db/tables/viewpoint-20.md).

# People-and-sites tables

{% hint style="info" %}
Generated from the staging database schema, with descriptions drafted by agents ([how to read these docs](https://docs.snapfix.com/how-to-read.md)). [Source on GitHub](https://github.com/snapfix/docs/blob/main/spec/db/tables/viewpoint-20.md).
{% endhint %}

## Description

Who belongs where: organisations, sites, groups, accounts, their site and group memberships, multi-sites, addresses and the user and group type codes.

## Tables

| Name                                                                                                      | Columns | Comment                                                                                                                                                                                                                                                                                                                     | Type       |
| --------------------------------------------------------------------------------------------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- |
| [enum\_BusinessType](https://docs.snapfix.com/engineering-reference/db/tables/enum_businesstype.md)       | 8       | The two group kinds, task and asset, with the code in uuid. No code reads the table: tPri\_Business.enum\_BusinessType holds the code, and the code compares it with the RegType values \[[ASK-246](https://github.com/snapfix/docs/blob/main/ASK.md#ask-246-should-the-enum-lookup-tables-follow-the-code-or-be-retired)]. | BASE TABLE |
| [enum\_UserType](https://docs.snapfix.com/engineering-reference/db/tables/enum_usertype.md)               | 9       | The three account kinds that tPri\_User.enum\_UserType holds, code in uuid: 1 normal, 2 snapfix (Snapfix internal user) and 3 snapfix\_test. No code reads the table \[[ASK-246](https://github.com/snapfix/docs/blob/main/ASK.md#ask-246-should-the-enum-lookup-tables-follow-the-code-or-be-retired)].                    | BASE TABLE |
| [tPri\_Address](https://docs.snapfix.com/engineering-reference/db/tables/tpri_address.md)                 | 13      | A postal address of a site, linked through tPri\_ParentAddress. Each address save adds a new row.                                                                                                                                                                                                                           | BASE TABLE |
| [tPri\_Business](https://docs.snapfix.com/engineering-reference/db/tables/tpri_business.md)               | 29      | A group of a site (UI: group), holding tasks and members, or an asset register; it carries the customer type and the soft-freeze settings.                                                                                                                                                                                  | BASE TABLE |
| [tPri\_MultiSite](https://docs.snapfix.com/engineering-reference/db/tables/tpri_multisite.md)             | 18      | A multi-site (UI name "Multi-Site Console"), a named set of sites managed together that can share checklist templates and members. Its sites are in tPri\_MultiSiteParent.                                                                                                                                                  | BASE TABLE |
| [tPri\_MultiSiteParent](https://docs.snapfix.com/engineering-reference/db/tables/tpri_multisiteparent.md) | 12      | Links a site (uuid\_tParent) to a multi-site (uuid\_tMultiSite).                                                                                                                                                                                                                                                            | BASE TABLE |
| [tPri\_MultiSiteUser](https://docs.snapfix.com/engineering-reference/db/tables/tpri_multisiteuser.md)     | 15      | A user's membership of a multi-site, with admin, active and visible flags. No code reads fAdmin \[[ASK-123](https://github.com/snapfix/docs/blob/main/ASK.md#ask-123-who-may-manage-a-multi-site-and-change-its-members-site-roles)].                                                                                       | BASE TABLE |
| [tPri\_Org](https://docs.snapfix.com/engineering-reference/db/tables/tpri_org.md)                         | 23      | A customer organisation that groups sites (tPri\_Parent.uuid\_tOrg), with its address, invoice and renewal dates and links to its Stripe, Xero and HubSpot records. No row is newer than 2024-08.                                                                                                                           | BASE TABLE |
| [tPri\_Parent](https://docs.snapfix.com/engineering-reference/db/tables/tpri_parent.md)                   | 46      | One site, the customer account that holds groups, buildings, users and tasks, with its address, customer type, payment package, billing dates, time zone and settings.                                                                                                                                                      | BASE TABLE |
| [tPri\_ParentAddress](https://docs.snapfix.com/engineering-reference/db/tables/tpri_parentaddress.md)     | 11      | Links a site to an address (tPri\_Address) with its type. Every save adds a row, and readers take the newest row of each type.                                                                                                                                                                                              | BASE TABLE |
| [tPri\_User](https://docs.snapfix.com/engineering-reference/db/tables/tpri_user.md)                       | 50      | One person's login account, shared by all their sites and groups, with name, username, mobile number, language, verification flags and login counters; the rows hold personal data. Password hashes are in tPri\_UserHashSalt.                                                                                              | BASE TABLE |
| [tPri\_UserBusiness](https://docs.snapfix.com/engineering-reference/db/tables/tpri_userbusiness.md)       | 41      | One person's membership of one group, with the group role, the membership state and the permission switches (such as create, delete, archive and move between red, amber and green).                                                                                                                                        | BASE TABLE |
| [tPri\_UserParent](https://docs.snapfix.com/engineering-reference/db/tables/tpri_userparent.md)           | 24      | One person's membership of one site, with the site role, on-call and block flags, and site permissions such as creating groups and managing tags.                                                                                                                                                                           | BASE TABLE |
| [tPub\_UserType](https://docs.snapfix.com/engineering-reference/db/tables/tpub_usertype.md)               | 3       | The group roles, Admin and User (tPri\_UserBusiness.uuid\_tUserType). php-apis looks the Admin row up by name, and the apps, apipy and the Laravel API read it.                                                                                                                                                             | BASE TABLE |

## Relations

```mermaid
erDiagram

"enum_BusinessType" }o--o| "tPri_User" : "FOREIGN KEY (uuid_tUser_CreatedBy) REFERENCES tPri_User (uuid)"
"tPri_Address" }o--o| "tPri_User" : "FOREIGN KEY (uuid_tUser_CreatedBy) REFERENCES tPri_User (uuid)"
"tPri_Business" }o--o| "tPri_Parent" : "FOREIGN KEY (uuid_tParent) REFERENCES tPri_Parent (uuid)"
"tPri_Business" }o--o| "tPri_User" : "FOREIGN KEY (uuid_tUser_CreatedBy) REFERENCES tPri_User (uuid)"
"tPri_Parent" }o--o| "tPri_User" : "FOREIGN KEY (uuid_tUser_CreatedBy) REFERENCES tPri_User (uuid)"
"tPri_ParentAddress" }o--o| "tPri_Address" : "FOREIGN KEY (uuid_tAddress) REFERENCES tPri_Address (uuid)"
"tPri_ParentAddress" }o--o| "tPri_Parent" : "FOREIGN KEY (uuid_tParent) REFERENCES tPri_Parent (uuid)"
"tPri_ParentAddress" }o--o| "tPri_User" : "FOREIGN KEY (uuid_tUser_CreatedBy) REFERENCES tPri_User (uuid)"
"tPri_User" }o--o| "tPri_User" : "FOREIGN KEY (uuid_tUser_CreatedBy) REFERENCES tPri_User (uuid)"
"tPri_UserBusiness" }o--o| "tPri_User" : "FOREIGN KEY (uuid_tUser_CreatedBy) REFERENCES tPri_User (uuid)"
"tPri_UserBusiness" }o--o| "tPri_Business" : "FOREIGN KEY (uuid_tBusiness) REFERENCES tPri_Business (uuid)"
"tPri_UserBusiness" }o--o| "tPri_User" : "FOREIGN KEY (uuid_tUser) REFERENCES tPri_User (uuid)"
"tPri_UserParent" }o--o| "tPri_User" : "FOREIGN KEY (uuid_tUser_CreatedBy) REFERENCES tPri_User (uuid)"
"tPri_UserParent" }o--o| "tPri_Parent" : "FOREIGN KEY (uuid_tParent) REFERENCES tPri_Parent (uuid)"
"tPri_UserParent" }o--o| "tPri_User" : "FOREIGN KEY (uuid_tUser) REFERENCES tPri_User (uuid)"

"enum_BusinessType" {
  varchar_255_ uuid_tUser_CreatedBy
}
"enum_UserType" {
}
"tPri_Address" {
  varchar_255_ uuid
  varchar_255_ uuid_tUser_CreatedBy
}
"tPri_Business" {
  varchar_255_ uuid
  varchar_255_ uuid_tParent
  varchar_255_ uuid_tUser_CreatedBy
}
"tPri_MultiSite" {
}
"tPri_MultiSiteParent" {
}
"tPri_MultiSiteUser" {
}
"tPri_Org" {
}
"tPri_Parent" {
  varchar_255_ uuid
  varchar_255_ uuid_tUser_CreatedBy
}
"tPri_ParentAddress" {
  varchar_255_ uuid_tAddress
  varchar_255_ uuid_tParent
  varchar_255_ uuid_tUser_CreatedBy
}
"tPri_User" {
  varchar_255_ uuid
  varchar_255_ uuid_tUser_CreatedBy
}
"tPri_UserBusiness" {
  varchar_255_ uuid_tBusiness
  varchar_255_ uuid_tUser
  varchar_255_ uuid_tUser_CreatedBy
}
"tPri_UserParent" {
  varchar_255_ uuid_tParent
  varchar_255_ uuid_tUser
  varchar_255_ uuid_tUser_CreatedBy
}
"tPub_UserType" {
}
```

***

> Generated by [tbls](https://github.com/k1LoW/tbls)


---

# 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://docs.snapfix.com/engineering-reference/db/tables/viewpoint-20.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.
