# company_trainee_assignments

## 概要

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

```sql
CREATE TABLE `company_trainee_assignments` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '割当ID',
  `company_id` bigint unsigned NOT NULL,
  `trainee_id` bigint unsigned NOT NULL,
  `start_date` date NOT NULL COMMENT '配属開始日',
  `end_date` date DEFAULT NULL COMMENT '配属終了日',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `uq_assignment` (`company_id`,`trainee_id`,`start_date`),
  KEY `company_trainee_assignments_trainee_id_foreign` (`trainee_id`),
  CONSTRAINT `company_trainee_assignments_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE,
  CONSTRAINT `company_trainee_assignments_trainee_id_foreign` FOREIGN KEY (`trainee_id`) REFERENCES `trainees` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
```

</details>

## カラム一覧

| 名前 | タイプ | デフォルト値 | NULL許可 | Extra Definition | 子テーブル | 親テーブル | コメント |
| ---- | ------ | ------------ | -------- | ---------------- | ---------- | ---------- | -------- |
| id | bigint unsigned |  | false | auto_increment |  |  | 割当ID |
| company_id | bigint unsigned |  | false |  |  | [companies](companies.md) |  |
| trainee_id | bigint unsigned |  | false |  |  | [trainees](trainees.md) |  |
| start_date | date |  | false |  |  |  | 配属開始日 |
| end_date | date |  | true |  |  |  | 配属終了日 |
| created_at | timestamp |  | true |  |  |  |  |
| updated_at | timestamp |  | true |  |  |  |  |

## 制約一覧

| 名前 | タイプ | 定義 |
| ---- | ---- | ---------- |
| company_trainee_assignments_company_id_foreign | FOREIGN KEY | FOREIGN KEY (company_id) REFERENCES companies (id) |
| company_trainee_assignments_trainee_id_foreign | FOREIGN KEY | FOREIGN KEY (trainee_id) REFERENCES trainees (id) |
| PRIMARY | PRIMARY KEY | PRIMARY KEY (id) |
| uq_assignment | UNIQUE | UNIQUE KEY uq_assignment (company_id, trainee_id, start_date) |

## INDEX一覧

| 名前 | 定義 |
| ---- | ---------- |
| company_trainee_assignments_trainee_id_foreign | KEY company_trainee_assignments_trainee_id_foreign (trainee_id) USING BTREE |
| PRIMARY | PRIMARY KEY (id) USING BTREE |
| uq_assignment | UNIQUE KEY uq_assignment (company_id, trainee_id, start_date) USING BTREE |

## ER図

![er](company_trainee_assignments.svg)

---

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