--这是我的设计的数据库中的表--acount用户帐号
--create network
--use network
create table account
(
aid int auto_increment not null,
username varchar(50) unique not null,
password varchar(50) not null,
email varchar(50) not null,
identity char(1) not null,
primary key (aid)
);
insert into account(username,password,email,identity) values('pang','pang','[email protected]',1);--用户信息
create table userinformation
(
uid int not null auto_increment,
name varchar(50) not null,
sex char(1) not null check('f' or 'm'),
email varchar(50) not null ,
u_age int not null check(u_age >= 0 and u_age <= 200) ,
u_adds varchar(200) ,
job varchar(50) ,
fav varchar(100) ,
tel varchar(50) ,
mobile_phone varchar(50),
school varchar(100) ,
uaid int unique not null ,
primary key (uid),
FOREIGN KEY(uaid) REFERENCES account(aid));
insert into userinformation(name,sex,email,u_age,uaid) values ('root','m','[email protected]',250,1);--空间留言
create table spaceword
(
swid int not null auto_increment,
name varchar(50) not null,
word text not null,
swlid int not null,
primary key (swid),
FOREIGN KEY (swlid) REFERENCES account(aid)
);
insert into spaceword(name,word,swlid) values('pang','helloWorld',1);
--日志信息
create table log
(
gid int auto_increment not null,
gtitle varchar(50) not null ,
gauthor varchar(50) not null ,
gtext text not null,
gdate datetime not null,
ghits long not null,
gcid int not null,
primary key (gid),
FOREIGN KEY (gcid) REFERENCES account(aid)
);
insert into log(gtitle,gauthor,gtext,gdate,ghits,gcid) values('news','news','news',now(),0,1);
--日志评论
create table logcomment
(
bid int not null auto_increment,
name varchar(50),
word text not null,
blid int not null,
primary key (bid),
FOREIGN KEY(blid) REFERENCES log(gid)
);
insert into logcomment(name,word,blid) values('pang','log hello word',1); 我想设计一个博客网站.但是在数据库的设计上出现点问题.
当我帐号登陆的时候,我会把我的帐号的id记录下来,博客的主页显示用户的信息,用户信息有一个外键对应的是帐号的id.日至中也有一个外键对应的也是帐号的id,但是这样设计有点不好,当我在访问别人的博客的时候调用变得很麻烦,我想知道一个博客的数据库应该怎么设计
--create network
--use network
create table account
(
aid int auto_increment not null,
username varchar(50) unique not null,
password varchar(50) not null,
email varchar(50) not null,
identity char(1) not null,
primary key (aid)
);
insert into account(username,password,email,identity) values('pang','pang','[email protected]',1);--用户信息
create table userinformation
(
uid int not null auto_increment,
name varchar(50) not null,
sex char(1) not null check('f' or 'm'),
email varchar(50) not null ,
u_age int not null check(u_age >= 0 and u_age <= 200) ,
u_adds varchar(200) ,
job varchar(50) ,
fav varchar(100) ,
tel varchar(50) ,
mobile_phone varchar(50),
school varchar(100) ,
uaid int unique not null ,
primary key (uid),
FOREIGN KEY(uaid) REFERENCES account(aid));
insert into userinformation(name,sex,email,u_age,uaid) values ('root','m','[email protected]',250,1);--空间留言
create table spaceword
(
swid int not null auto_increment,
name varchar(50) not null,
word text not null,
swlid int not null,
primary key (swid),
FOREIGN KEY (swlid) REFERENCES account(aid)
);
insert into spaceword(name,word,swlid) values('pang','helloWorld',1);
--日志信息
create table log
(
gid int auto_increment not null,
gtitle varchar(50) not null ,
gauthor varchar(50) not null ,
gtext text not null,
gdate datetime not null,
ghits long not null,
gcid int not null,
primary key (gid),
FOREIGN KEY (gcid) REFERENCES account(aid)
);
insert into log(gtitle,gauthor,gtext,gdate,ghits,gcid) values('news','news','news',now(),0,1);
--日志评论
create table logcomment
(
bid int not null auto_increment,
name varchar(50),
word text not null,
blid int not null,
primary key (bid),
FOREIGN KEY(blid) REFERENCES log(gid)
);
insert into logcomment(name,word,blid) values('pang','log hello word',1); 我想设计一个博客网站.但是在数据库的设计上出现点问题.
当我帐号登陆的时候,我会把我的帐号的id记录下来,博客的主页显示用户的信息,用户信息有一个外键对应的是帐号的id.日至中也有一个外键对应的也是帐号的id,但是这样设计有点不好,当我在访问别人的博客的时候调用变得很麻烦,我想知道一个博客的数据库应该怎么设计
在你的应用逻辑中控制哪些该显示给用户,哪些不该显示给用户。