# account_contract

## Description

<details>
<summary><strong>Table Definition</strong></summary>

```sql
CREATE TABLE `account_contract` (
  `account_contract_id` mediumint unsigned NOT NULL AUTO_INCREMENT,
  `account_id` mediumint unsigned NOT NULL,
  `contract_id` mediumint unsigned NOT NULL,
  `is_primary_for_calc` tinyint(1) DEFAULT NULL,
  PRIMARY KEY (`account_contract_id`),
  UNIQUE KEY `uidx_account_contract_contract` (`contract_id`),
  KEY `fk_account_contract_account_id` (`account_id`),
  CONSTRAINT `fk_account_contract_account_id` FOREIGN KEY (`account_id`) REFERENCES `account` (`account_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_account_contract_contract_id` FOREIGN KEY (`contract_id`) REFERENCES `contract` (`contract_id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=[Redacted by tbls] DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
```

</details>

## Columns

| Name                | Type               | Default | Nullable | Extra Definition | Children | Parents                 | Comment |
| ------------------- | ------------------ | ------- | -------- | ---------------- | -------- | ----------------------- | ------- |
| account_contract_id | mediumint unsigned |         | false    | auto_increment   |          |                         |         |
| account_id          | mediumint unsigned |         | false    |                  |          | [account](account.md)   |         |
| contract_id         | mediumint unsigned |         | false    |                  |          | [contract](contract.md) |         |
| is_primary_for_calc | tinyint(1)         |         | true     |                  |          |                         |         |

## Constraints

| Name                            | Type        | Definition                                                  |
| ------------------------------- | ----------- | ----------------------------------------------------------- |
| PRIMARY                         | PRIMARY KEY | PRIMARY KEY (account_contract_id)                           |
| fk_account_contract_account_id  | FOREIGN KEY | FOREIGN KEY (account_id) REFERENCES account (account_id)    |
| fk_account_contract_contract_id | FOREIGN KEY | FOREIGN KEY (contract_id) REFERENCES contract (contract_id) |
| uidx_account_contract_contract  | UNIQUE      | UNIQUE KEY uidx_account_contract_contract (contract_id)     |

## Indexes

| Name                           | Definition                                                          |
| ------------------------------ | ------------------------------------------------------------------- |
| PRIMARY                        | PRIMARY KEY (account_contract_id) USING BTREE                       |
| fk_account_contract_account_id | KEY fk_account_contract_account_id (account_id) USING BTREE         |
| uidx_account_contract_contract | UNIQUE KEY uidx_account_contract_contract (contract_id) USING BTREE |

## Relations

![er](account_contract.svg)

---

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