《在线图书商城》-- 数据库设计2016。
6.5数据库在在一个信息管理系统中占有非常重要的地位,数据库结构设计的好坏将直接对应用系统的效率以及实现的效果产生影响。
数据库设计一般包括以下四个部分:数据库需求分析、数据库概念结构设计、数据库逻辑结构设计、数据库物理结构实现。
一、数据库需求分析系统主要分为两部分,一个为普通会员用户部分,亦即前台系统.另外一个是系统的管理员部分,即后台系统。
网上书店前台系统部分主要是实现网上选书、购书、产生订单等功能的系统。
后台实现书籍管理、用户管理、订单处理等功能。
开发工具:Microsoft SQLServer 2000开发语言:SQL二、数据库概念结构设计系统共有九个实体:客户、管理员、图书类型、图书、订单、详细订单、参数设置、图书评价、信息反馈。
(1)客户(会员)的属性:自动编号CustomerId、客户名、客户密码、真实姓名、性别、客户电话、E—mail、地址、注册时间、提示问题、问题答案、登陆次数、最近登陆时间、邮编(2)管理员的属性:自动编号AdminId、管理员名称、管理员邮箱、密码、权限标志(3)图书类型的属性:自动编号BookTypeId、类别名称(4)图书的属性:自动编号BookId、图书名称、图书类型、出版社、出版日期、开本、版次、图书作者、图书译者、图书ISBN、图书定价、图书页码、图书简介、图书目录、市场价、会员价、成交量、浏览次数、折扣、图书封面图、图书库存量、入库时间、封装方式2.图书信息3。
管理员信息4.客户信息5。
订单信息6.图书评论信三、据库逻辑结构设计 & 数据库物理结构实现1.客户(会员):问题,问题答案,登陆次数,最近登陆时间,邮编)表1:客户信息表tb_customerinfo代码实现:tb_customerinfocreate table tb_customerinfo (CustomerId int identity,CustomerName varchar(20) not null,CustomerPwd varchar(20) not null,Customertruename varchar(20) not null,CustomerSex varchar(2) not nullconstraint CKC_CUSTOMERSEX_TB_CUSTO check (CustomerSex in ('男’,'女')),CustomerTel varchar(20) not null,CustomerEmail varchar(20) not null,CustomerAddr varchar(20) not null,CustomerRegTime datetime not null,CustomerQues varchar(200) null,CustomerAnswer varchar(200) null,CustomerLogTime int not null,CustomerLastLogT datetime not null,constraint PK_TB_CUSTOMERINFO primary key(CustomerId, CustomerName)2.管理员:表2:管理员信息表tb_manager代码实现:tb_managercreate table tb_manager (AdminId int identity, AdminName varchar(10) not null, AdminPwd varchar(20) not null, AdminFlag int not null, constraint PK_TB_MANAGER primary key (AdminId))3.图书类型表3:图书类型信息表tb_booktypeinfo代码实现:tb_booktypeinfocreate table tb_booktypeinfo (BookTypeId int identity, BookTypeName varchar(50) not null,constraint PK_TB_BOOKTYPEINFO primary key (BookTypeId))4.图书ISBN,图书定价,图书页码,图书简介,图书目录,市场价,会员价,成交量,浏览次数,折扣,图书封面图,图书库存量,入库时间、封装方式)表4:图书信息表tb_bookinfo代码实现:tb_bookinfocreate table tb_bookinfo (BookId int identity, BookTypeId int not null,BookName varchar(20) not null, BookType varchar(10) not null, BookPress varchar(20) not null, BookPubDate datetime not null,BookSize varbinary(10) not null,BookVersion varchar(10) not null,BookAuthor varchar(10) not null, BookTanslor varchar(10) null,Bookisbn varchar(20) not null, BookPrice money not null,BookPages int not null, BookOutline varchar(200) not null, BookCatalog varchar(200) not null,BookMprice money not null, BookPrprice money not null,BookDealmount int not null,BookLookmount int null,BookDiscount varchar(10) not null, BookPic money not null, BookStoremount int not null,BookStoretime datetime not null, BookPackstyle varchar(20) not null, constraint PK_TB_BOOKINFO primary key (BookId))5.购物车临时订购信息表5:购物车临时订购信息tb_shopbook代码实现:tb_shopbookcreate table tb_shopbook (CustomerId int not null,BookId int not null,ordermount int not null,price money not null,ispay varchar(10) not null default ’未付款’constraint CKC_ISPAY_TB_SHOPB check (ispay in ('未付款',’已付款')), constraint PK_TB_SHOPBOOK primary key (CustomerId, BookId))6.订单收货地址,收货人联系方式,备注,总卖出价)表6:订单信息表tb_order代码实现:table tb_ordercreate table tb_order (Id int identity, OrderId varchar(20) not null, CustomerId int not null,Orderdate datetime not null, Ordermount int not null, message varchar(100) null,postmethod varchar(100) not null, paymethod varchar(100) not null, recevername varchar(10) not null, receveraddr varchar(20) not null, recevertel varchar(10) not null, memo varchar(100) null,totalprice money not null,constraint PK_TB_ORDER primary key (OrderId))7.详细订单表7:订单详细信息表tb_orderdetail代码实现:tb_orderdetailcreate table tb_orderdetail (id int identity,OrderDetailId varchar(20) not null,OrderId varchar(20) not null,BookId int not null,ordermount int not null,poststatus varchar(10) not null default ’未发货'constraint CKC_POSTSTATUS_TB_ORDER check (poststatus in (’未发货’,'已发货’)), Recevstatus varchar(10) not null default '未收货'constraint CKC_RECEVSTATUS_TB_ORDER check (Recevstatus in ('未收货’,’已收货’)),sigletotalprice money not null,constraint PK_TB_ORDERDETAIL primary key (OrderDetailId))8.图书评价表8:图书评价信息表tb_comment代码实现:tb_commentcreate table tb_comment (CommentId int not null,BookId int not null, CustomerId int not null, Customername varchar(20) not null, Commentdate datetime not null, Commentcontent varchar(100) not null, Commentflag varchar(10) not null, constraint PK_TB_COMMENT primary key (CommentId))9.信息反馈客户IP)表9:信息反馈信息表tb_reply代码实现:tb_replycreate table tb_reply (ReplyId int not null, CustomerId int not null, ReplyType varchar(20) not null, Replytitle varchar(20) not null, Replycontent varchar(100) not null, Customername varchar(20) not null, Commentdate datetime not null, CustomerIP varchar(10) not null, constraint PK_TB_REPLY primary key (ReplyId))10.参数设置信息代码实现:table tb_parametertb_ create table tb_parameter (webname varchar(20) not null,regtiaoyue varchar(100) not null, notice varchar(100) not null,address varchar(20) not null,postcode varchar(10) not null, tel varchar(10) not null, copyright varchar(20) not null, weblogo varchar(100) not null, website varchar(10) not null, affordmethod varchar(100) not null, shopstream varchar(100) not null, postmethod varchar(100) not null, postprice money not null, Postdescp varchar(100) not null, worktime varchar(20) not null,service varchar(100) not null, law varchar(100) not null, commques varchar(100) not null, dealrule varchar(100) not null, constraint PK_TB_PARAMETER primary key (webname))。