数据库搭建:搭建网站信息存储结构?

2023-10-11 | 品牌网站


一、建立网站信息存储结构

1、建立用户表:

用户表主要用于存储用户信息,包括用户ID、用户名、用户密码、用户邮箱、用户地址、用户状态等字段。

2、建立文章表:

文章表用于存储文章信息,包括文章ID、文章标题、文章内容、文章作者、文章分类等字段。

3、建立文章分类表:

文章分类表用于存储文章的分类信息,包括文章分类ID、文章分类名称、文章分类描述等字段。

4、建立评论表:

评论表用于存储用户对文章的评论信息,包括评论ID、评论文章ID、评论内容、评论用户ID等字段。

5、建立点赞表:

点赞表用于存储用户对文章的点赞信息,包括点赞ID、点赞文章ID、点赞用户ID等字段。

二、数据库搭建

1、建立用户表:

create table user(
id int primary key auto_increment,
username varchar(20) not null,
password varchar(20) not null,
email varchar(50) not null,
address varchar(100) not null,
status int not null
);

2、建立文章表:

create table article(
id int primary key auto_increment,
title varchar(50) not null,
content text not null,
author varchar(20) not null,
category_id int not null
);

3、建立文章分类表:

create table category(
id int primary key auto_increment,
name varchar(20) not null,
description varchar(50) not null
);

4、建立评论表:

create table comment(
id int primary key auto_increment,
article_id int not null,
content text not null,
user_id int not null
);

5、建立点赞表:

create table like(
id int primary key auto_increment,
article_id int not null,
user_id int not null
);

相关案例

更多案例

相关文章

更多观点