# trainees

## 概要

<details>
<summary><strong>テーブル定義</strong></summary>

```sql
CREATE TABLE `trainees` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '実習生ID',
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '氏名',
  `code` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '外部連携用の実習生コード',
  `birthdate` date DEFAULT NULL COMMENT '生年月日',
  `gender` enum('M','F') COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '性別',
  `entry_date` date DEFAULT NULL COMMENT '入国日',
  `exit_date` date DEFAULT NULL COMMENT '帰国日または予定日',
  `status` enum('在留中','帰国','退職') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '在留中' COMMENT '在留状態',
  `program_type` enum('1号','2号','3号','特定技能') COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '制度種別',
  `sending_agency_id` bigint unsigned DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `trainees_code_unique` (`code`),
  KEY `trainees_sending_agency_id_foreign` (`sending_agency_id`),
  CONSTRAINT `trainees_sending_agency_id_foreign` FOREIGN KEY (`sending_agency_id`) REFERENCES `sending_agencies` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
```

</details>

## カラム一覧

| 名前 | タイプ | デフォルト値 | NULL許可 | Extra Definition | 子テーブル | 親テーブル | コメント |
| ---- | ------ | ------------ | -------- | ---------------- | ---------- | ---------- | -------- |
| id | bigint unsigned |  | false | auto_increment | [archive_logs](archive_logs.md) [company_trainee_assignments](company_trainee_assignments.md) [invoice_items](invoice_items.md) [invoice_templates](invoice_templates.md) |  | 実習生ID |
| name | varchar(255) |  | false |  |  |  | 氏名 |
| code | varchar(255) |  | false |  |  |  | 外部連携用の実習生コード |
| birthdate | date |  | true |  |  |  | 生年月日 |
| gender | enum('M','F') |  | true |  |  |  | 性別 |
| entry_date | date |  | true |  |  |  | 入国日 |
| exit_date | date |  | true |  |  |  | 帰国日または予定日 |
| status | enum('在留中','帰国','退職') | 在留中 | false |  |  |  | 在留状態 |
| program_type | enum('1号','2号','3号','特定技能') |  | true |  |  |  | 制度種別 |
| sending_agency_id | bigint unsigned |  | true |  |  | [sending_agencies](sending_agencies.md) |  |
| created_at | timestamp |  | true |  |  |  |  |
| updated_at | timestamp |  | true |  |  |  |  |

## 制約一覧

| 名前 | タイプ | 定義 |
| ---- | ---- | ---------- |
| PRIMARY | PRIMARY KEY | PRIMARY KEY (id) |
| trainees_code_unique | UNIQUE | UNIQUE KEY trainees_code_unique (code) |
| trainees_sending_agency_id_foreign | FOREIGN KEY | FOREIGN KEY (sending_agency_id) REFERENCES sending_agencies (id) |

## INDEX一覧

| 名前 | 定義 |
| ---- | ---------- |
| trainees_sending_agency_id_foreign | KEY trainees_sending_agency_id_foreign (sending_agency_id) USING BTREE |
| PRIMARY | PRIMARY KEY (id) USING BTREE |
| trainees_code_unique | UNIQUE KEY trainees_code_unique (code) USING BTREE |

## ER図

![er](trainees.svg)

---

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