# for Emacs: -*- mode: org; mode: flyspell; fill-column: 79 -*

# This is a subset of tables in our CRM. Do not look for consistency here

| TABLE     | action_item     |      |   |   |
| id        | Integer         | PK   |   |   |
| date_done | Timestamp       | NULL |   |   |
| priority  | Integer         |      |   |   |
| se_nb     | FK sales_entity |      |   |   |
| status    | Integer         |      |   |   |
| what_done | Text            |      |   |   |
| who_done  | FK staff        |      |   |   |

| TABLE         | config  |    |   |   |
| id            | Integer | PK |   |   |
| sales_message | Boolean |    |   |   |

| TABLE         | contract        |          |   |   |
| contract_nb   | Integer         | PK       |   |   |
| contract_type | Integer         | NOT NULL |   |   |
| se_nb         | FK sales_entity | NOT NULL |   |   |

| TABLE          | mailing_list |          |   |   |
| default_status | FK tn_status | NOT NULL |   |   |
| id             | Integer      | PK       |   |   |
| name           | Text         | NOT NULL |   |   |

| TABLE             | mailing_list_recipients           |          |   |   |
| id                | Integer                           | PK       |   |   |
| email             | FK staff_email                    | NOT NULL |   |   |
| list              | FK mailing_list                   | NOT NUL  |   |   |
| subscription_type | FK mailing_list_subscription_type | NOT NULL |   |   |

| TABLE | mailing_list_subscription_type |          |   |   |
| id    | Integer                        | PK       |   |   |
| name  | Text                           | NOT NULL |   |   |

| TABLE | region  |    |   |   |
| id    | Integer | PK |   |   |
| name  | Text    |    |   |   |

| TABLE        | sales_entity |          |   |   |
| act_Nb       | integer      |          |   |   |
| date_created | date         |          |   |   |
| region       | FK region    | NOT NULL |   |   |
| sales_rep    | FK staff     | NOT NULL |   |   |
| se_nb        | Integer      | PK       |   |   |

| TABLE           | staff          |          |      |   |
| active          | Boolean        |          | true |   |
| id              | Integer        | PK       |      |   |
| login           | Text           | NOT NULL |      |   |
| preferred_email | FK staff_email | NULL     |      |   |
| region          | FK region      | NOT NULL |      |   |
| salary          | Money          | NOT NULL |      |   |

| TABLE         | staff_email |          |   |   |
| email_address | Text        | NOT NULL |   |   |
| id            | Integer     | PK       |   |   |
| staff         | FK staff    |          |   |   |

| TABLE           | subscription |          |   |   |
| subscription_nb | FK contract  | PK       |   |   |
| contract_type   | Integer      | NOT NULL |   |   |

| TABLE | tn_status |          |   |   |
| id    | Integer   | PK       |   |   |
| name  | Text      | NOT NULL |   |   |

| TABLE      | tracking_number |          |   |   |
| assignee   | FK staff        | NOT NULL |   |   |
| created_by | FK staff        | NULL     |   |   |
| tn         | Text            | PK       |   |   |

| TABLE         | wavefront           |          |   |   |
| comment       | Text                |          |   |   |
| delivered_by  | FK staff            | NULL     |   |   |
| delivery_date | Date                |          |   |   |
| id            | Integer             | PK       |   |   |
| request_date  | Date                |          |   |   |
| requested_by  | Integer             |          |   |   |
| se_nb         | FK sales_entity     | NOT NULL |   |   |
| status        | FK wavefront_status | NOT NULL |   |   |

| TABLE | wavefront_status |          |   |   |
| id    | Integer          | PK       |   |   |
| name  | Text             | NOT NULL |   |   | 

| TABLE | wavefront_tn       |          |   |   |
| id    | Integer            | PK       |   |   |
| tn    | FK tracking_number | NOT NULL |   |   |
| wave  | FK wavefront       | NOT NULL |   |   |
