新闻系统数据库设计

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

1根据需求分析的结果规划出的实体有:管理员实体、单条新闻实体、新闻版块实体、新闻评论实体管理员表(admin)Sql:DROPDATABASEIFEXISTS`webnews`;CREATEDATABASE`webnews`;USE`webnews`;CREATETABLEadmin(adminIDint(4)NOTNULLauto_increment,adminTypeint(4)notnull,adminNamechar(30)notnull,loginNamechar(30)notnull,loginPwdchar(30)notnull,PRIMARYKEY(adminID))ENGINE=InnoDBDEFAULTCHARSET=gb2312;INSERTINTOadmin(adminID,adminType,adminName,loginName,loginPwd)VALUES(1,1,'系统管理员','admin1','admin1');INSERTINTOadmin(adminID,adminType,adminName,loginName,loginPwd)VALUES(2,2,'新闻管理员','admin2','admin2');INSERTINTOadmin(adminID,adminType,adminName,loginName,loginPwd)VALUES(3,3,'会员管理员','admin3','admin3');INSERTINTOadmin(adminID,adminType,adminName,LoginName,LoginPwd)VALUES(4,4,'评论管理员','admin4','admin4');会员表(Member)字段名类型长度是否为空注释默认值memberIDint4Notnull主键,会员ID无loginNamevarchar50Notnull登录名无loginPwdvarchar50Notnull登录密码无realNamevarchar50Notnull真实姓名无emailvarchar100Notnull会员email无CREATETABLEmember(memberIDint(4)NOTNULLauto_increment,loginNamechar(50)notnull,loginPwdchar(50)notnull,realNamechar(50)notnull,emailvarchar(100)notnull,PRIMARYKEY(memberID))ENGINE=InnoDBDEFAULTCHARSET=gb2312;INSERTINTOmember(memberID,loginName,loginPwd,realName,email)VALUES(1,'member1','member1','会员1号','member1@163.com');INSERTINTOmember(memberID,loginName,loginPwd,realName,email)VALUES(2,'member2','member2','会员2号','member2@163.com');INSERTINTOmember(memberID,loginName,loginPwd,realName,email)VALUES(3,'member3','member3','会员3号','member3@163.com');INSERTINTOmember(memberID,loginName,loginPwd,realName,email)VALUES(4,'member4','member4','会员4号','member4@163.com');INSERTINTOmember(memberID,loginName,loginPwd,realName,email)VALUES(5,'member5','member5','会员5号','member5@163.com');INSERTINTOmember(memberID,loginName,loginPwd,realName,email)VALUES(6,'member6','member6','会员6号','member6@163.com');INSERTINTOmember(memberID,loginName,loginPwd,realName,email)VALUES(7,'member7','member7','会员7号','member7@163.com');INSERTINTOmember(memberID,loginName,loginPwd,realName,email)VALUES(8,'member8','member8','会员8号','member8@163.com');INSERTINTOmember(memberID,loginName,loginPwd,realName,email)VALUES(9,'member9','member9','会员9号','member9@163.com');INSERTINTOmember(memberID,loginName,loginPwd,realName,email)VALUES(10,'member10','member10','会员10号','member10@163.com');新闻评论表(Comments)字段名类型长度是否为空注释默认值CommentIDint4否主键评论标识(无)reviewerint4是外键评论者姓名(会员ID)(无)Titlevarchar100否评论标题(无)ContentText16否评论内容(无)CommentDateDatetime8否评论时间Now()newsIDint4是外键所属新闻ID(无)CREATETABLEcomments(commentIDint(4)NOTNULLauto_increment,reviewerint(4),newsint(4),titlevarchar(100)notNULL,contenttextnotnull,commentDatedatetimenotnull,PRIMARYKEY(commentID),foreignkey(reviewer)referencesmember(memberID)ondeletecascade,foreignkey(news)referencesnews(newsID)ondeletecascade)ENGINE=InnoDBDEFAULTCHARSET=gb2312;INSERTINTOcomments(commentID,reviewer,news,title,content,commentDate)VALUES(1,1,1,'真假?','火箭就是垃圾',now());INSERTINTOcomments(commentID,reviewer,news,title,content,commentDate)VALUES(2,2,1,'强大的队伍正常表现','期待火箭会越来越好',now());INSERTINTOcomments(commentID,reviewer,news,title,content,commentDate)VALUES(3,1,3,'真假?','饭岛爱死了,太可惜了。多好的一人啊!',now());INSERTINTOcomments(commentID,reviewer,news,title,content,commentDate)VALUES(4,1,2,'读书?','读书到死',now());INSERTINTOcomments(commentID,reviewer,news,title,content,commentDate)VALUES(5,2,1,'真假?','我也是',now());新闻版块表(section)字段名类型长度是否为空注释默认值sectionIDint4否主键版块标识(无)sectionNameVarchar30否模板名(无)descriptionVarchar100是版块描述(无)CREATETABLEsection(sectionIDint(4)NOTNULLauto_increment,sectionNamevarchar(30)notNULL,descriptionvarchar(100),PRIMARYKEY(sectionID))ENGINE=InnoDBDEFAULTCHARSET=gb2312;INSERTINTOsection(sectionID,sectionName,description)VALUES(1,'NBA','NBA赛事最新最快信息');INSERTINTOsection(sectionID,sectionName,description)VALUES(2,'读书','读书时代,今天你读书了吗?');INSERTINTOsection(sectionID,sectionName,description)VALUES(3,'财经','财经报道,股票、基金');INSERTINTOsection(sectionID,sectionName,description)VALUES(4,'娱乐','我最八卦');INSERTINTOsection(sectionID,sectionName,description)VALUES(5,'军事','最新军事报道');INSERTINTOsection(sectionID,sectionName,description)VALUES(6,'时事','国内外时事');新闻表(news)字段名类型长度是否为空注释默认值NewsIDint4否主键新闻标识(无)submtDatedatetime8否新闻提交时间now()Authorvarchar50否记者姓名(无)Titlevarchar100否新闻标题(无)Contenttext16否新闻内容(无)sectionIDint4是外键所属版块(无)keyWordsVarchar100是关键字(无)clickedTimesInt4否点击次数0picturevarchar(100)varchar(100)是图片,存放图片路径defaultNULLCREATETABLEnews(newsIDint(4)NOTNULLauto_increment,sectionint(4)notnull,titlevarchar(100)notNULL,authorvarchar(50)notnull,contenttextnotnull,keyWordsvarchar(100)notNULL,submitDatedatetimenotnull,clickedTimesint(4)default0,picturevarchar(100),PRIMARYKEY(newsID),foreignkey(section)referencessection(sectionID)ondeletecascade)ENGINE=InnoDBDEFAULTCHARSET=gb2312;INSERTINTOnews(newsID,section,title,author,content,keywords,submitDate,clickedTimes,picture)VALUES(1,1,'火箭四连败','小猫','正文四连败','nba火箭',now(),0,'图片1');INSERTINTOnews(newsID,section,title,author,content,keywords,submitDate,clickedTimes,picture)VALUES(2,2,'我在读书','小明','正文我在读书,别烦我!','读书',now(),0,'图片2');INSERTINTOnews(newsID,sect

1 / 6
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功