25 lines
1.2 KiB
SQL
25 lines
1.2 KiB
SQL
-- 创建数据库
|
|
CREATE DATABASE IF NOT EXISTS yuminail DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
|
|
|
USE yuminail;
|
|
|
|
-- 商品收藏表
|
|
create table t_wishlist
|
|
(
|
|
id bigint unsigned auto_increment comment '收藏记录唯一主键ID'
|
|
primary key comment '商品收藏主键索引',
|
|
user_id bigint unsigned not null comment '关联用户表主键',
|
|
product_id bigint unsigned not null comment '关联商品表主键',
|
|
create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间',
|
|
update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
|
|
is_delete tinyint unsigned default 0 null comment '逻辑删除:0-未删除,1-已删除',
|
|
constraint uk_user_product
|
|
unique (user_id, product_id) comment '用户-商品唯一索引'
|
|
) comment '商品收藏表';
|
|
|
|
create index idx_user_id
|
|
on t_wishlist (user_id) comment '按用户查询收藏的索引';
|
|
|
|
create index idx_product_id
|
|
on t_wishlist (product_id) comment '按商品查询收藏的索引';
|