Articles#
An article is a single communication record attached to a ticket — an inbound email, an outbound reply, a phone-call note, an internal note, or a chat message. Every article belongs to exactly one ticket.
Article storage is split across two tables: article holds the metadata common to all communication channels, and article_data_mime holds the email-specific content (subject, body, headers).
The article Table#
One row per communication event. Contains channel and visibility metadata.
Column |
Type |
Description |
|---|---|---|
|
BIGINT |
Primary key. Referenced by |
|
BIGINT |
The ticket this article belongs to. Joins to |
|
SMALLINT |
Who sent this article (agent, customer, or system). Joins to |
|
BIGINT |
Which channel the article came through. Joins to |
|
SMALLINT |
|
|
DATETIME |
When the article was created. |
|
INTEGER |
Agent who created the article. Joins to |
The article_data_mime Table#
One row per MIME (email) article. Contains the actual message content. Always joined to article via article_id.
Column |
Type |
Description |
|---|---|---|
|
BIGINT |
Primary key. |
|
BIGINT |
Joins to |
|
MEDIUMTEXT |
The From header (sender name and address). |
|
MEDIUMTEXT |
The Reply-To header. |
|
MEDIUMTEXT |
The To header. |
|
MEDIUMTEXT |
The Cc header. |
|
MEDIUMTEXT |
The Bcc header. |
|
TEXT |
The email subject line. |
|
TEXT |
The RFC 2822 Message-ID header. Used for threading. |
|
MEDIUMTEXT |
The message body. May be plain text or HTML depending on |
|
VARCHAR(250) |
MIME content type of the body (e.g. |
|
INTEGER |
Unix epoch of when the message was received. |
|
DATETIME |
When the record was written. |
Sender Type and Channel#
article_sender_type — resolves article.article_sender_type_id
Name |
Meaning |
|---|---|
|
Written or sent by a Znuny agent. |
|
Sent by a customer contact. |
|
Generated automatically by the system. |
communication_channel — resolves article.communication_channel_id
Standard channels:
Name |
Meaning |
|---|---|
|
MIME email (inbound or outbound). |
|
Phone call note created by an agent. |
|
Internal note, not visible to customers. |
|
Chat message (if the chat feature is enabled). |
Typical Article Queries#
All external emails on a ticket:
SELECT
adm.a_from,
adm.a_to,
adm.a_subject,
adm.a_body,
a.create_time,
ast.name AS sender_type,
cc.name AS channel
FROM article a
JOIN article_data_mime adm ON adm.article_id = a.id
JOIN article_sender_type ast ON ast.id = a.article_sender_type_id
JOIN communication_channel cc ON cc.id = a.communication_channel_id
WHERE a.ticket_id = :ticket_id
AND a.is_visible_for_customer = 1
ORDER BY a.create_time;
Count of inbound emails received per day:
SELECT
DATE(a.create_time) AS day,
COUNT(*) AS inbound_emails
FROM article a
JOIN article_sender_type ast ON ast.id = a.article_sender_type_id
JOIN communication_channel cc ON cc.id = a.communication_channel_id
WHERE ast.name = 'customer'
AND cc.name = 'Email'
GROUP BY DATE(a.create_time)
ORDER BY day DESC;