标签系统mysql设计_关于tag标签系统的实现

本文介绍了如何在实验室项目中实现用户主题的标签功能,包括数据库表设计:tag表、topic表和tag_topic映射表,以及逻辑实现步骤,如用户创建主题时标签的插入更新。还提及了对这种方法效率的担忧。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

实验室的项目,需要做对用户发布的主题进行打标签的功能,纠结甚久,实现思路如下:

一、数据库表的设计

1.tag表

create table qa_tag

(

tag_id int primary key auto_increment,

tag_name varchar(32) not null,

tag_time timestamp not null default CURRENT_TIMESTAMP,

refered_cnt int not null default 0,

user_id int not null,

unique (tag_name),

constraint foreign key (user_id) references user_info(user_id)

);

2.topic表

create table qa_topic

(

topic_id int primary key auto_increment,

topic_title varchar(128) not null,

topic_body text not null,

topic_time timestamp not null default CURRENT_TIMESTAMP,

user_id int not null,

tags varchar(128) not null default ''

);

3.tag与topic的映射表

create table qa_tag_topic

(

record_id int primary key auto_increment,

tag_id int not null,

topic_id int not null,

co

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值