博客系统
1.用户(users)
用户名( username)
密码 ( password)
昵称(nickname)
头像(avatar )
2.文章(articles)
标题( title)
正文( content)
作者( author_id)
发表时间(commented _at)
3.评论
用户( user_id)
文章( article_id)
评论时间(commented _at)
create table users(
id int unsigned primary key auto_increment,
username varchar(20) not null unique,
password varchar(1024) not null ,
nickname varchar(20) not null,
avatar varchar(200) not null
);
create table articles(
id int unsigned primary key auto_increment,
title varchar(200) not null,
content text not null,
author_id int unsigned not null,
published_at timestamp default current_timestamp,
foreign key (author_id)refernces users(id)
);
create table comments(
id bigint unsigned primary key auto_increment,
user_id int unsigned not null,
article_id int unsigned not null,
commented _at timestamp default current_timestamp,
foreign key (article_id )refernces articles(id),
foreign key (user_id)refernces users(id)
);