Skip to content

Latest commit

 

History

History
82 lines (65 loc) · 2.03 KB

accounts.md

File metadata and controls

82 lines (65 loc) · 2.03 KB

accounts

Description

Twitterなどのアカウントテーブル

Table Definition
CREATE TABLE `accounts` (
  `id` char(36) NOT NULL,
  `type` tinyint(1) NOT NULL,
  `name` varchar(256) DEFAULT NULL,
  `url` text DEFAULT NULL,
  `user_id` char(36) NOT NULL,
  `created_at` datetime(6) DEFAULT NULL,
  `updated_at` datetime(6) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `fk_users_accounts` (`user_id`),
  CONSTRAINT `fk_users_accounts` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3

Columns

Name Type Default Nullable Children Parents Comment
id char(36) false アカウントUUID
type tinyint(1) false アカウントのハードコードID
name varchar(256) NULL true アカウント名
url text NULL true アカウントのURL
user_id char(36) false users ユーザーUUID
created_at datetime(6) NULL true
updated_at datetime(6) NULL true

Constraints

Name Type Definition
fk_users_accounts FOREIGN KEY FOREIGN KEY (user_id) REFERENCES users (id)
PRIMARY PRIMARY KEY PRIMARY KEY (id)

Indexes

Name Definition
fk_users_accounts KEY fk_users_accounts (user_id) USING BTREE
PRIMARY PRIMARY KEY (id) USING BTREE

Relations

erDiagram

"accounts" }o--|| "users" : "FOREIGN KEY (user_id) REFERENCES users (id)"

"accounts" {
  char_36_ id PK
  tinyint_1_ type
  varchar_256_ name
  text url
  char_36_ user_id FK
  datetime_6_ created_at
  datetime_6_ updated_at
}
"users" {
  char_36_ id PK
  text description
  tinyint_1_ check
  varchar_32_ name
  tinyint_1_ state
  datetime_6_ created_at
  datetime_6_ updated_at
}
Loading

Generated by tbls