Lookup Tables#
Every ID column in the ticket table resolves to a name in a small lookup table. This page is a quick-reference join cheat-sheet.
State#
ticket_state — resolves ticket.ticket_state_id
Column |
Type |
Description |
|---|---|---|
|
SMALLINT |
Primary key. Referenced by |
|
VARCHAR(200) |
State name shown in the UI (e.g. |
|
SMALLINT |
The state’s behavioral category. Joins to |
|
VARCHAR(25) |
Hex color used for this state in the UI. |
|
SMALLINT |
|
ticket_state_type — resolves ticket_state.type_id
The state type controls system behavior regardless of the state’s display name:
Type name |
Behavior |
|---|---|
|
Ticket has not yet been worked on. |
|
Ticket is being actively worked on. |
|
Ticket is resolved and no longer active. |
|
Ticket is waiting; a reminder fires at the pending time. |
|
Ticket transitions to another state automatically at the pending time. |
|
Ticket is archived and hidden from normal views. |
|
Ticket has been merged into another ticket. |
Join pattern:
JOIN ticket_state ts ON ts.id = t.ticket_state_id
JOIN ticket_state_type tst ON tst.id = ts.type_id
Priority#
ticket_priority — resolves ticket.ticket_priority_id
Column |
Type |
Description |
|---|---|---|
|
SMALLINT |
Primary key. Referenced by |
|
VARCHAR(200) |
Priority name (e.g. |
|
VARCHAR(25) |
Hex color used for this priority in the UI. |
|
SMALLINT |
|
Type#
ticket_type — resolves ticket.type_id
Column |
Type |
Description |
|---|---|---|
|
SMALLINT |
Primary key. Referenced by |
|
VARCHAR(200) |
Type name (e.g. |
|
SMALLINT |
|
Queue#
queue — resolves ticket.queue_id
Key columns for reporting:
Column |
Type |
Description |
|---|---|---|
|
INTEGER |
Primary key. Referenced by |
|
VARCHAR(200) |
Full queue name, including parent path separated by |
|
INTEGER |
The permission group that controls access to this queue. Joins to |
|
INTEGER |
Default first-response SLA time in minutes (NULL = none). |
|
INTEGER |
Default update SLA time in minutes (NULL = none). |
|
INTEGER |
Default solution SLA time in minutes (NULL = none). |
|
SMALLINT |
|
Agents#
users — resolves ticket.user_id and ticket.responsible_user_id
Column |
Type |
Description |
|---|---|---|
|
INTEGER |
Primary key. Referenced by |
|
VARCHAR(200) |
Agent username. Unique. |
|
VARCHAR(100) |
First name. |
|
VARCHAR(100) |
Last name. |
|
SMALLINT |
|
Join pattern for owner name:
JOIN users u ON u.id = t.user_id
-- then use: CONCAT(u.first_name, ' ', u.last_name)
Validity#
valid — the validity flag table referenced by most configuration tables
Column |
Type |
Description |
|---|---|---|
|
SMALLINT |
Primary key ( |
|
VARCHAR(200) |
Human-readable name: |
For reporting you almost always want to filter on valid_id = 1 when joining lookup tables to exclude deactivated states, queues, priorities, or agents.
Master Join Template#
A template that resolves the most common ID columns in one query:
SELECT
t.tn,
t.title,
ts.name AS state,
tst.name AS state_type,
tp.name AS priority,
tt.name AS ticket_type,
q.name AS queue,
CONCAT(u.first_name, ' ', u.last_name) AS owner,
t.create_time,
t.change_time
FROM ticket t
JOIN ticket_state ts ON ts.id = t.ticket_state_id
JOIN ticket_state_type tst ON tst.id = ts.type_id
JOIN ticket_priority tp ON tp.id = t.ticket_priority_id
LEFT JOIN ticket_type tt ON tt.id = t.type_id
JOIN queue q ON q.id = t.queue_id
JOIN users u ON u.id = t.user_id
WHERE t.archive_flag = 0;