Skip to content

Latest commit

 

History

History
96 lines (79 loc) · 3.01 KB

group_user_belongings.md

File metadata and controls

96 lines (79 loc) · 3.01 KB

group_user_belongings

Description

グループとユーザー関係テーブル

Table Definition
CREATE TABLE `group_user_belongings` (
  `user_id` char(36) NOT NULL,
  `group_id` char(36) NOT NULL,
  `since_year` smallint(4) NOT NULL,
  `since_semester` tinyint(1) NOT NULL,
  `until_year` smallint(4) NOT NULL,
  `until_semester` tinyint(1) NOT NULL,
  `created_at` datetime(6) DEFAULT NULL,
  `updated_at` datetime(6) DEFAULT NULL,
  PRIMARY KEY (`user_id`,`group_id`),
  KEY `fk_group_user_belongings_group` (`group_id`),
  CONSTRAINT `fk_group_user_belongings_group` FOREIGN KEY (`group_id`) REFERENCES `groups` (`group_id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `fk_group_user_belongings_user` 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
user_id char(36) false users ユーザーUUID
group_id char(36) false groups グループUUID
since_year smallint(4) false ユーザー所属開始年
since_semester tinyint(1) false ユーザー所属開始学期(0:前期 1:後期)
until_year smallint(4) false ユーザー所属終了年
until_semester tinyint(1) false ユーザー所属終了学期(0:前期 1:後期)
created_at datetime(6) NULL true 関係テーブル作成日時
updated_at datetime(6) NULL true 関係テーブル更新日時

Constraints

Name Type Definition
fk_group_user_belongings_group FOREIGN KEY FOREIGN KEY (group_id) REFERENCES groups (group_id)
fk_group_user_belongings_user FOREIGN KEY FOREIGN KEY (user_id) REFERENCES users (id)
PRIMARY PRIMARY KEY PRIMARY KEY (user_id, group_id)

Indexes

Name Definition
fk_group_user_belongings_group KEY fk_group_user_belongings_group (group_id) USING BTREE
PRIMARY PRIMARY KEY (user_id, group_id) USING BTREE

Relations

erDiagram

"group_user_belongings" }o--|| "users" : "FOREIGN KEY (user_id) REFERENCES users (id)"
"group_user_belongings" }o--|| "groups" : "FOREIGN KEY (group_id) REFERENCES groups (group_id)"

"group_user_belongings" {
  char_36_ user_id PK
  char_36_ group_id PK
  smallint_4_ since_year
  tinyint_1_ since_semester
  smallint_4_ until_year
  tinyint_1_ until_semester
  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
}
"groups" {
  char_36_ group_id PK
  varchar_32_ name
  text link
  text description
  datetime_6_ created_at
  datetime_6_ updated_at
}
Loading

Generated by tbls