diff --git a/sql/highlight.sql b/sql/highlight.sql new file mode 100644 index 0000000..2b1ec94 --- /dev/null +++ b/sql/highlight.sql @@ -0,0 +1,64 @@ +-- README +-- idx_ = index +-- fk_ = foreign +-- Create an index for fast lookups +-- Defining constraints separately for better readability & maintainability + +-- Item table + +create table if not exists `catalog_item` ( + `id` int(11) not null auto_increment primary key, + name varchar(36) not null +) engine=InnoDB default charset=utf8mb4; + +-- Main table + +create table if not exists `highlight_category` ( + `id` int(11) not null auto_increment primary key, + `title` longtext not null, + `desc` longtext default null, + `background` longtext default null, + `illustration` longtext default null +) engine=InnoDB default charset=utf8mb4; + +-- Bridge table + +/* +create table if not exists `highlight_` ( + `id` int(11) not null auto_increment primary key, + `` int(11) not null, + `category` int(11) not null, + key `idx_` (``), + key `idx_category` (`category`), + constraint `highlight__fk_` + foreign key (``) references `` (``) + on update cascade + on delete cascade, + constraint `highlight_videdu_fk_category` + foreign key (`category`) references `highlight_category` (`id`) + on update cascade + on delete cascade +) engine=InnoDB default charset=utf8mb4; +*/ + +-- = Your reference module name : "catalog" [2] +-- = Your FK field name : "item" [5] +--
= Your reference table name : "catalog_item" [1] +-- = Your reference table PK : "id" [1] + +create table if not exists `highlight_catalog` ( + `id` int(11) not null auto_increment primary key, + `item` int(11) not null, + `category` int(11) not null, + key `idx_item` (`item`), + key `idx_category` (`category`), + constraint `highlight_catalog_fk_item` + foreign key (`item`) references `catalog_item` (`id`) + on update cascade + on delete cascade, + constraint `highlight_videdu_fk_category` + foreign key (`category`) references `highlight_category` (`id`) + on update cascade + on delete cascade +) engine=InnoDB default charset=utf8mb4; +