宠物社交网站数据库设计
项目简介:用户通过给自己的宠物申请账号,从而在网路上以宠物为第一人称与其他宠物进行社交(类似微博)。
数据库基本架构:
用户(ID,用户名,密码,邮箱,电话,地址,身份证号,性别,姓名,生日)
宠物(ID,名字,性别,生日,智商,简介,用户ID,品种ID)
科目(ID,科目名)
品种(ID,品种名,科目ID)
动态(ID,用户ID,内容,时间,赞数)
评论(ID,用户ID,内容,时间,动态ID)
回复(ID,用户ID,内容,时间,评论ID)
管理员(ID,用户名,密码)
用户表
create table user(
-> id int not null auto_increment,
-> usr_name varchar(20) not null,
-> password varchar(20) not null,
-> email varchar(20) not null,
-> tel varchar(11),
-> address varchar(50),
-> sex boolean,
-> true_name varchar(20),
-> birthday Date,
-> primary key(id));
宠物表
create table pet(
-> id int not null auto_increment,
-> name varchar(20) not null,
-> sex boolean,
-> birthday Date,
-> IQ int,
-> intro varchar(200),
-> user_id int not null,
-> kind_id int not null,
-> primary key(id));
//设置外键
alter table pet add constraint fk_pet_user foreign key(user_id) references user(id) on delete cascade on update cascade;
alter table pet add constraint fk_pet_kind foreign key(kind _id) references kind (id) on delete cascade on update cascade;
科目表
mysql> create table family(
-> id int not null primary key auto_increment,
-> family varchar(20));
品种表
mysql> create table kind(
-> id int not null primary key auto_increment,
-> kind varchar(20) not null,
-> family_id int not null);
//设置外键
alter table kind add constraint fk_breed_family foreign key(family_id) references family(id) on delete cascade on update cascade;
动态表
mysql> create table dynamic(
-> id int not null primary key auto_increment,
-> user_id int not null,
-> content varchar(280) not null,
-> time time not null,
-> praise int);
//设置外键
alter table dongtai add constraint fk_dynamic_user foreign key(user_id)
references user(id) on delete cascade on update cascade;
评论表
mysql> create table comment(
-> id int not null primary key auto_increment,
-> user_id int not null,
-> content varchar(280) not null,
-> time time not null,
-> from_id int not null);
//设置外键
alter table comment add constraint fk_comment_user foreign key(user_id) references user(id) on delete cascade on update cascade;
alter table comment add constraint fk_comment_dongtai foreign key(from_id) references dongtai(id) on delete cascade on update cascade;
管理员表
mysql> create table admin(
-> id int not null primary key auto_increment,
-> name varchar(20) not null,
-> password varchar(20) not null);
回复表
create table reply_comment(
id int not null auto_increment,
user_id int not null,
time Time not null,
owner_id int not null,
primary key(id));
//设置外键
alter table reply_comment add constraint fk_reply_user foreign key(user_id) references user(id) on delete cascade on update cascade;
alter table reply_comment add constraint fk_reply_comment foreign key(owner_id) references comment(id) on delete cascade on update cascade;
相关推荐
经典的ASP.NET教程,对数据库的操作指导深入浅出,值得收藏!
ASP.NET 数据库 入门 经典 C# 编程
经典的ASP.NET教程,在数据库的操作指导深入浅出,值得收藏!
自己学数据库过程中做的笔记,希望对你有帮助
经典的ASP.NET教程,在数据库的操作指导深入浅出,值得收藏!
该资源是关于Oracle数据库的入门知识,内容不是很深入,非常适合初学者阅读,我自己也是初学者,我觉得还不错,希望能帮倒需要的朋友!
该项目整体工作量还可以,基于MFC最难的控件list控件,包括各种单击事件触发,列表排序等,虽然该项目整体书写,包括命名等都略显弱智,不过不失为一个MFC入门的好材料
电子书籍ASP.NET数据库入门经典--C#编程篇 关于ASP.NET的学习
《ASP.NET数据库入门经典--C#编程篇》是一本不错的书,看看吧!
MySQL入门学习(1)。 MySQL入门学习(1) · 安装篇 PHP+MySQL+Linux目前已逐渐成为小型web服务器的一种经典组合。在indows环境下构筑和调试MySQL数据库是许多网站开发者的一种首选。本人在Windows98环境下...
oracle新手入门指导之一——数据库表空间知识.txtoracle新手入门指导之一——数据库表空间知识.txt
《分布式数据库架构及企业实践——基于Mycat中间件》对 Mycat 从入门到进阶、从高级技术实践到架构剖析、从网络通信协议解析到系统工作原理的方方面面进行了详细讲解,并剖析了 Mycat的 SQL 路由、跨库联合查询、...
Python项目案例开发从入门到实战源代码第3章 数据库应用——智力问答测试
管理员通过MySQL数据库添加管理员操作添加管理员用户,然后管理员通过Web后台网页登录界面进行管理员账号登陆,进入主界面后可以从左侧导航栏选择页面功能,页面功能包含首页信息、用户管理、路灯管理、故障管理...
金融数据库——02sas系统快速入门.pptx
数据库操作入门教程——SQL基本语句学习
数据库SQL Sever入门教程PPT以及基础性原代码
很好地DB2入门知识,很好,你值得拥有!
•第1章Delphi 7 集成开发环境(IDE)介绍 •第2章Delphi 7数据库系统概述 •第3章Delphi 7和数据库 •第4章创建数据库 •第5章读写字段值 •第6章计算字段 ...•第17章数据库开发实例——学生管理系统
一本基于数据库应用的J2EE开发入门书籍 带你一步步走进J2EE殿堂