用mysql怎么做tag系统_关于tag标签系统的实现

本文介绍了如何使用MySQL设计并实现一个标签系统,包括tag表、topic表和映射表的创建,以及用户创建主题时标签的处理逻辑,包括数据插入、更新和查询操作。虽然未测试效率,但提供了完整的数据库和业务流程设计。
摘要由CSDN通过智能技术生成

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

一、数据库表的设计

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 i

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值