# invoice_items

## 概要

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

```sql
CREATE TABLE `invoice_items` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '明細ID',
  `invoice_id` bigint unsigned NOT NULL,
  `trainee_id` bigint unsigned DEFAULT NULL,
  `description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '請求項目名',
  `amount` decimal(12,2) NOT NULL COMMENT '金額（税抜）',
  `tax_category` enum('課税','不課税','非課税') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '課税' COMMENT '税区分',
  `note` text COLLATE utf8mb4_unicode_ci COMMENT '備考',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `invoice_items_invoice_id_foreign` (`invoice_id`),
  KEY `invoice_items_trainee_id_foreign` (`trainee_id`),
  CONSTRAINT `invoice_items_invoice_id_foreign` FOREIGN KEY (`invoice_id`) REFERENCES `invoices` (`id`) ON DELETE CASCADE,
  CONSTRAINT `invoice_items_trainee_id_foreign` FOREIGN KEY (`trainee_id`) REFERENCES `trainees` (`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
```

</details>

## カラム一覧

| 名前 | タイプ | デフォルト値 | NULL許可 | Extra Definition | 子テーブル | 親テーブル | コメント |
| ---- | ------ | ------------ | -------- | ---------------- | ---------- | ---------- | -------- |
| id | bigint unsigned |  | false | auto_increment |  |  | 明細ID |
| invoice_id | bigint unsigned |  | false |  |  | [invoices](invoices.md) |  |
| trainee_id | bigint unsigned |  | true |  |  | [trainees](trainees.md) |  |
| description | varchar(255) |  | true |  |  |  | 請求項目名 |
| amount | decimal(12,2) |  | false |  |  |  | 金額（税抜） |
| tax_category | enum('課税','不課税','非課税') | 課税 | false |  |  |  | 税区分 |
| note | text |  | true |  |  |  | 備考 |
| created_at | timestamp |  | true |  |  |  |  |
| updated_at | timestamp |  | true |  |  |  |  |

## 制約一覧

| 名前 | タイプ | 定義 |
| ---- | ---- | ---------- |
| invoice_items_invoice_id_foreign | FOREIGN KEY | FOREIGN KEY (invoice_id) REFERENCES invoices (id) |
| invoice_items_trainee_id_foreign | FOREIGN KEY | FOREIGN KEY (trainee_id) REFERENCES trainees (id) |
| PRIMARY | PRIMARY KEY | PRIMARY KEY (id) |

## INDEX一覧

| 名前 | 定義 |
| ---- | ---------- |
| invoice_items_invoice_id_foreign | KEY invoice_items_invoice_id_foreign (invoice_id) USING BTREE |
| invoice_items_trainee_id_foreign | KEY invoice_items_trainee_id_foreign (trainee_id) USING BTREE |
| PRIMARY | PRIMARY KEY (id) USING BTREE |

## ER図

![er](invoice_items.svg)

---

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