SQL query for highlight
This commit is contained in:
parent
dfa0c52247
commit
8ce49202e0
64
sql/highlight.sql
Normal file
64
sql/highlight.sql
Normal file
@ -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_<item>` (
|
||||||
|
`id` int(11) not null auto_increment primary key,
|
||||||
|
`<fk>` int(11) not null,
|
||||||
|
`category` int(11) not null,
|
||||||
|
key `idx_<fk>` (`<fk>`),
|
||||||
|
key `idx_category` (`category`),
|
||||||
|
constraint `highlight_<item>_fk_<fk>`
|
||||||
|
foreign key (`<fk>`) references `<table>` (`<pk>`)
|
||||||
|
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;
|
||||||
|
*/
|
||||||
|
|
||||||
|
-- <item> = Your reference module name : "catalog" [2]
|
||||||
|
-- <fk> = Your FK field name : "item" [5]
|
||||||
|
-- <table> = Your reference table name : "catalog_item" [1]
|
||||||
|
-- <pk> = 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;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user