首页 > 文章资讯 > 软件资讯 > 正文

电脑购物网页制作含数据库_网上购物数据库设计

无心下载站2022-08-15 05:48:27

数据库结构一览

  数据库结构

详细分解

功能表

  功能表

  功能表用于保存系统的功能及其路径,方便做权限管理

角色表

  角色表

  将系统中的各种用户区分为不同的角色,不同的角色赋予不同的功能,以实现系统的权限划分

角色权限表

  角色权限表

  这里将角色和功能做对应,就可以实现赋予不同的角色不同的权限

管理员表

  管理员表

  这张表中存放的是系统的管理员用户,或者说是工作人员可能会更为准确,给不同的工作人员赋予不同的角色,如:有的不服管理商品,有的负责更新活动

用户表

  用户表

  这是商城的实际用户,也就是消费者,这里只记录一些基本信息

用户地址表

  用户地址表

  同一个用户可能有多个收货地址,在这里就存放每一位用户的收货地址即可

用户积分表

  用户积分表

  这张表主要记录用户的积分明细,如什么时候积分因为什么原因增加多少,什么时候以为什么原因减少多少

商品分类表

  商品分类表

  这张表主要记录商品的大类,如:蔬菜,水果,其他等

商品分类附加信息表

  商品分类附加信息表

  这张表用于记录某一大类商品所具有的共有特性,比如:肉类这一大类所有的共有特性为:出自哪家屠宰场,出自哪家养殖场。这张表就是为了记录某一大类的共有属性而设计的

商品表

  商品表

  这里记录的就是商品的信息,具体看图,不做赘述了

商品附加信息表

  商品附加信息表

  这张表是与上文的【商品分类附加信息表】做对应,记录某一商品继承与他的大类的附加属性的信息

商品规格表

  商品规格表

  这里是存放的某一商品在购买是可选的规格,比如我需要购买一杯饮料,就可以选择,是否加糖,是否加冰,大中小杯等

商品规格选项表

  规格选项表1

  规格选项表2

  这里就是不同规格的选项了,就是大杯、中杯这样的选项

收藏与购物车

  收藏与购物车

  收藏与购物车,这里的大概的思路就是记录用户在什么时候将什么商品加入购物车(添加到收藏),不同的是,收藏只需要记录商品信息就可以了,但购物车还需要记录用户购买的数量与规格信息

活动表

  活动表

  记录活动的名称、活动时间及活动商品,表1是活动的信息,表2是活动的具体商品

优惠券

  优惠券

  这里主要记录的是商场现有的优惠券的基本信息,包活:有效期、满足金额(积分)才能获取到优惠券,优惠金额,消费金额,优惠券类型等信息

用户优惠券

  用户优惠券表

  记录用户所有的优惠券及其状态

  销售表与销售信息表

  销售表

  销售信息表

  这两张表组合起来记录用户的购买行为,具体内容看图片哦!

系统配置表

  系统配置表

  用户记录一些系统的配置信息,比如消费积分的兑换比例等

最后说几句

  ok,数据库大概就是这个样子啦,我觉得写的应该比较通俗易懂了吧,小白看应该没啥问题,要是有大佬看了,一定一定要给出意见,在系统设计上我知道还应该多学习,但是苦于无处拜师,只得在头条求大神指点了!!

彩蛋

  前一篇文章底下有好多小伙伴叫我开源!好的!没有问题,我现在就给各位小伙伴开源了!代码在下面,虽然只有数据库代码,但这应该也算开源吧~~

  create table Shop_Function(

  func_name nvarchar(32) not null, --功能名称

  func_path nvarchar(32) not null, --功能路径

  func_icon nvarchar(256) not null, --图标

  primary key(func_name)

  );

  go

  create table Shop_Role(

  role_id int identity(1,1) unique not null, --编号

  role_name nvarchar(32) not null, --角色名称

  role_ramarks ntext not null, --备注

  role_type int not null, --角色所属的类型(0,管理员,1,后台用户)

  primary key(role_id)

  );

  go

  create table Shop_Role_Function(

  role_id_fk int not null, --角色编号

  func_name_fk nvarchar(32) not null, --功能编号

  foreign key (role_id_fk) References Shop_Role(role_id) ON DELETE CASCADE ON UPDATE CASCADE,

  foreign key (func_name_fk) References Shop_Function(func_name) ON DELETE CASCADE ON UPDATE CASCADE,

  primary key(role_id_fk,func_name_fk)

  );

  go

  create table Shop_Admin(

  admin_id int identity(1,1) unique not null, --编号

  admin_name nvarchar(32) not null, --用户姓名

  admin_tel nvarchar(16) not null, --联系电话

  admin_wechat nvarchar(256) not null, --微信号

  admin_pwd nvarchar(256) not null, --密码

  role_id_fk int not null, --角色编号

  foreign key (role_id_fk) References Shop_Role(role_id) ON DELETE CASCADE ON UPDATE CASCADE,

  primary key(admin_id)

  );

  go

  create table Shop_User(

  u_id int identity(1,1) unique not null, --编号

  u_name nvarchar(32) not null, --用户姓名

  u_tel nvarchar(16) not null, --联系电话

  u_wechat nvarchar(256) not null, --微信号

  u_pwd nvarchar(256) not null, --密码

  u_invitation int not null, --邀请人

  u_signDate bigint not null, --注册时间

  u_lastLoginDate bigint not null, --上次登录时间

  primary key(u_id)

  );

  go

  create table Shop_User_Address(

  ua_id int identity(1,1) unique not null, --地址编号

  u_id_fk int not null, --用户编号

  ua_name nvarchar(256) not null, --收货姓名

  ua_tel nvarchar(18) not null, --收货电话

  ua_address nvarchar(256) not null, --收货地址

  foreign key (u_id_fk) References Shop_User(u_id) ON DELETE CASCADE ON UPDATE CASCADE,

  primary key(ua_id)

  );

  go

  create table Shop_User_Integral(

  ui_id int identity(1,1) unique not null, --积分编号

  u_id_fk int not null, --用户编号

  ui_num float not null, --积分数目(可正可负)

  ui_date bigint not null, --记录时间

  ua_remarks nvarchar(256) not null, --说明

  foreign key (u_id_fk) References Shop_User(u_id) ON DELETE CASCADE ON UPDATE CASCADE,

  primary key(ui_id)

  );

  go

  create table Shop_Commodity_Type(

  ct_name nvarchar(32) not null, --分类名称

  ct_remarks nvarchar(256) not null, --分类说明

  ct_image ntext not null, --分类图表

  primary key(ct_name)

  );

  go

  create table Shop_Commodity_Type_Extend(

  ct_name_fk nvarchar(32) not null, --所属分组

  cte_name nvarchar(256) not null, --名称

  cte_remarks nvarchar(256) not null, --说明

  foreign key (ct_name_fk) References Shop_Commodity_Type(ct_name) ON DELETE CASCADE ON UPDATE CASCADE,

  primary key(ct_name_fk,cte_name)

  );

  go

  create table Shop_Commodity(

  com_id int identity(1,1) unique not null, --编号

  com_name nvarchar(32) not null, --名称

  com_price float not null, --价格

  com_min_order float not null, --最小数量

  com_unit nvarchar(32) not null, --单位

  ct_name_fk nvarchar(32) not null, --所属分组

  com_discount float not null, --折扣

  com_remarks ntext not null, --备注

  com_state int not null, --状态,0,下架,1,上架

  com_video nvarchar(256) not null, --视频

  com_image1 nvarchar(256) not null, --图片1

  com_image2 nvarchar(256) not null, --图片2

  com_image3 nvarchar(256) not null, --图片3

  com_image4 nvarchar(256) not null, --图片4

  com_image5 nvarchar(256) not null, --图片5

  com_order nvarchar(256) not null, --排序,从0开始,数值越大越靠前

  com_box float not null, --包装费

  foreign key (ct_name_fk) References Shop_Commodity_Type(ct_name) ON DELETE CASCADE ON UPDATE CASCADE,

  primary key(com_id)

  );

  go

  create table Shop_Commodity_info(

  com_id_fk int not null, --商品编号

  cte_name_fk nvarchar(256) not null, --说明名称

  comi_info nvarchar(256) not null, --说明信息

  foreign key (com_id_fk) References Shop_Commodity(com_id) ON DELETE CASCADE ON UPDATE CASCADE,

  primary key(com_id_fk,cte_name_fk)

  );

  go

  create table Shop_Commodity_Specifications(

  cspe_id int identity(1,1) unique not null, --规格ID

  com_id_fk int not null, --商品编号

  cspe_name nvarchar(32) not null, --规格名称

  cspe_remarks nvarchar(128) not null, --规格说明

  foreign key (com_id_fk) References Shop_Commodity(com_id) ON DELETE CASCADE ON UPDATE CASCADE,

  primary key(com_id_fk,cspe_name)

  );

  go

  create table Shop_Commodity_Specifications_Item(

  cspei_id int identity(1,1) unique not null, --规格选项ID

  cspe_id_fk int not null, --规格ID

  cspei_item nvarchar(32) not null, --规格选项

  cspei_money float not null, --加价

  foreign key (cspe_id_fk) References Shop_Commodity_Specifications(cspe_id) ON DELETE CASCADE ON UPDATE CASCADE,

  primary key(cspei_id)

  );

  go

  create table Shop_Collection(

  col_id int identity(1,1) unique not null, --收藏ID

  u_id_fk int not null, --用户编号

  com_id_fk int not null, --商品编号

  col_date bigint not null, --收藏日期

  foreign key (u_id_fk) References Shop_User(u_id) ON DELETE CASCADE ON UPDATE CASCADE,

  foreign key (com_id_fk) References Shop_Commodity(com_id) ON DELETE CASCADE ON UPDATE CASCADE,

  primary key(col_id)

  );

  go

  create table Shop_Shop_Car(

  car_id int identity(1,1) unique not null, --收藏ID

  u_id_fk int not null, --用户编号

  com_id_fk int not null, --商品编号

  car_num float not null, --数量

  car_extend ntext not null, --规格数据

  car_date bigint not null, --收藏日期

  foreign key (u_id_fk) References Shop_User(u_id) ON DELETE CASCADE ON UPDATE CASCADE,

  foreign key (com_id_fk) References Shop_Commodity(com_id) ON DELETE CASCADE ON UPDATE CASCADE,

  primary key(car_id)

  );

  go

  create table Shop_Activity(

  ac_id int identity(1,1) unique not null, --活动ID

  ac_name nvarchar(256) not null, --活动名称

  ac_image nvarchar(256) not null, --活动图片

  ac_begin_date bigint not null, --开始日期

  ac_end_date bigint not null, --结束日期

  primary key(ac_id)

  );

  go

  create table Shop_Activity_Commodity(

  ac_id_fk int not null, --活动ID

  com_id_fk int not null, --商品编号

  acc_min_order float not null, --最小数量

  acc_discount float not null, --折扣

  foreign key (ac_id_fk) References Shop_Activity(ac_id) ON DELETE CASCADE ON UPDATE CASCADE,

  foreign key (com_id_fk) References Shop_Commodity(com_id) ON DELETE CASCADE ON UPDATE CASCADE,

  primary key(ac_id_fk,com_id_fk)

  );

  go

  create table Shop_Recommend(

  com_id_fk int not null, --商品编号

  rec_order int not null, --推荐排序,1-99,数字越大越靠前

  foreign key (com_id_fk) References Shop_Commodity(com_id) ON DELETE CASCADE ON UPDATE CASCADE,

  primary key(com_id_fk)

  );

  go

  create table Shop_Discount(

  dis_code bigint not null, --优惠券编号

  dis_having_time int not null, --有效日期

  dis_type_money float not null, --满足金额(积分)才能获取到优惠券

  dis_money float not null, --优惠金额

  dis_satisfy_money float not null, --满足金额

  dis_type int not null, --优惠券类型(全场,大类,商品)

  dis_choose nvarchar(32) not null, --选择

  dis_remark nvarchar(32) not null, --选择备注

  dis_get int not null, --获取方式

  dis_state int not null, --状态

  primary key(dis_code)

  );

  go

  create table Shop_User_Discount(

  udis_id int identity(1,1) unique not null, --优惠券编号

  dis_code_fk bigint not null, --优惠券编号

  udis_satisfy_money float not null, --满足金额

  udis_money float not null, --优惠金额

  udis_type int not null, --类行

  udis_choose nvarchar(32) not null, --类行

  udis_remark nvarchar(32) not null, --类行

  u_id_fk int not null, --商品编号,如果为0则是全场任意商品优惠

  udis_begin_time bigint not null, --获得日期

  udis_having_time bigint not null, --有效日期

  udis_state int not null, --状态(1---有效,2---过期,3----使用)

  foreign key (u_id_fk) References Shop_User(u_id) ON DELETE CASCADE ON UPDATE CASCADE,

  primary key(udis_id)

  );

  go

  create table Shop_Sale(

  sa_code nvarchar(32) not null, --流水号

  u_id_fk int not null, --用户编号

  sa_address nvarchar(256) not null, --地址

  sa_tel nvarchar(18) not null, --联系电话

  sa_post_money float not null, --邮费

  sa_post_code nvarchar(32) not null, --快递单号

  sa_state int not null, --状态

  sa_name nvarchar(256) not null, --联系人

  sa_date bigint not null, --销售日期(时间戳 毫秒)

  sa_remarks nvarchar(32) not null, --备注

  sa_send_time nvarchar(32) not null, --发货时间

  sa_delivery nvarchar(32) not null, --配送站名称

  foreign key (u_id_fk) References Shop_User(u_id) ON DELETE CASCADE ON UPDATE CASCADE,

  primary key(sa_code)

  );

  go

  create table Shop_Sale_Info(

  si_id int identity(1,1) unique not null, --编号

  sa_code_fk nvarchar(32) not null, --所属销售表

  com_id_fk int not null, --冗余菜单ID

  com_name_fks nvarchar(32) not null, --冗余菜单名称

  com_unit_fks nvarchar(8) not null, --冗余单位

  mspei_json ntext not null, --规格信息json串

  si_num float not null, --数量

  si_money_base float not null, --原单价

  si_money float not null, --实际售价

  dis_code_fk bigint not null, --优惠券编码

  foreign key (sa_code_fk) References Shop_Sale(sa_code) ON DELETE CASCADE ON UPDATE CASCADE,

  foreign key (com_id_fk) References Shop_Commodity(com_id) ON DELETE CASCADE ON UPDATE CASCADE,

  primary key(si_id)

  );

  go

  create table Shop_Integral(

  in_id int identity(1,1) unique not null, --编号

  in_date bigint not null, --记录日期

  in_remarks ntext not null, --备注

  in_num float not null, --积分数目

  u_id_fk int not null, --用户ID

  foreign key (u_id_fk) References Shop_User(u_id) ON DELETE CASCADE ON UPDATE CASCADE,

  primary key(in_id)

  );

  go

  create table Shop_Delivery(

  de_id int identity(1,1) unique not null, --编号

  de_name nvarchar(32) not null, --站点名称

  de_address ntext not null, --地址

  de_tel nvarchar(32) not null, --联系电话

  de_people nvarchar(32) not null, --联系人

  primary key(de_id)

  );

  go

  create table Shop_UserExtension(

  ue_code nvarchar(32) not null, --邀请码

  u_id_fk int not null, --用户

  foreign key (u_id_fk) References Shop_User(u_id) ON DELETE CASCADE ON UPDATE CASCADE,

  primary key(ue_code)

  );

  go

  create table Shop_SystemConfig(

  sc_key nvarchar(32) not null, --配置键

  sc_value nvarchar(32) not null, --配置值

  primary key(sc_key)

  );

  -------------------------------------------------

  go

  create view view_Shop_Role_Function

  as

  select * from Shop_Role_Function

  inner join Shop_Role on Shop_Role_Function.role_id_fk=Shop_Role.role_id

  inner join Shop_Function on Shop_Role_Function.func_name_fk=Shop_Function.func_name

  go

  create view view_Shop_Admin

  as

  select * from Shop_Admin

  inner join Shop_Role on Shop_Admin.role_id_fk=Shop_Role.role_id

  go

  create view view_Shop_User_Address

  as

  select * from Shop_User_Address

  inner join Shop_User on Shop_User_Address.u_id_fk=Shop_User.u_id

  go

  create view view_Shop_User_Integral

  as

  select * from Shop_User_Integral

  inner join Shop_User on Shop_User_Integral.u_id_fk=Shop_User.u_id

  go

  create view view_Shop_Commodity_Type_Extend

  as

  select * from Shop_Commodity_Type_Extend

  inner join Shop_Commodity_Type on Shop_Commodity_Type_Extend.ct_name_fk=Shop_Commodity_Type.ct_name

  go

  create view view_Shop_Commodity

  as

  select * from Shop_Commodity

  inner join Shop_Commodity_Type on Shop_Commodity.ct_name_fk=Shop_Commodity_Type.ct_name

  go

  create view view_Shop_Commodity_info

  as

  select * from Shop_Commodity_info

  inner join Shop_Commodity on Shop_Commodity_info.com_id_fk=Shop_Commodity.com_id

  inner join Shop_Commodity_Type on Shop_Commodity.ct_name_fk=Shop_Commodity_Type.ct_name

  go

  create view view_Shop_Commodity_Specifications

  as

  select * from Shop_Commodity_Specifications

  inner join Shop_Commodity on Shop_Commodity_Specifications.com_id_fk=Shop_Commodity.com_id

  inner join Shop_Commodity_Type on Shop_Commodity.ct_name_fk=Shop_Commodity_Type.ct_name

  go

  create view view_Shop_Commodity_Specifications_Item

  as

  select * from Shop_Commodity_Specifications_Item

  inner join Shop_Commodity_Specifications on Shop_Commodity_Specifications_Item.cspe_id_fk=Shop_Commodity_Specifications.cspe_id

  inner join Shop_Commodity on Shop_Commodity_Specifications.com_id_fk=Shop_Commodity.com_id

  inner join Shop_Commodity_Type on Shop_Commodity.ct_name_fk=Shop_Commodity_Type.ct_name

  go

  create view view_Shop_Collection

  as

  select * from Shop_Collection

  inner join Shop_User on Shop_Collection.u_id_fk=Shop_User.u_id

  inner join Shop_Commodity on Shop_Collection.com_id_fk=Shop_Commodity.com_id

  inner join Shop_Commodity_Type on Shop_Commodity.ct_name_fk=Shop_Commodity_Type.ct_name

  go

  create view view_Shop_Shop_Car

  as

  select * from Shop_Shop_Car

  inner join Shop_User on Shop_Shop_Car.u_id_fk=Shop_User.u_id

  inner join Shop_Commodity on Shop_Shop_Car.com_id_fk=Shop_Commodity.com_id

  inner join Shop_Commodity_Type on Shop_Commodity.ct_name_fk=Shop_Commodity_Type.ct_name

  go

  create view view_Shop_Activity_Commodity

  as

  select * from Shop_Activity_Commodity

  inner join Shop_Activity on Shop_Activity_Commodity.ac_id_fk=Shop_Activity.ac_id

  inner join Shop_Commodity on Shop_Activity_Commodity.com_id_fk=Shop_Commodity.com_id

  inner join Shop_Commodity_Type on Shop_Commodity.ct_name_fk=Shop_Commodity_Type.ct_name

  go

  create view view_Shop_Recommend

  as

  select * from Shop_Recommend

  inner join Shop_Commodity on Shop_Recommend.com_id_fk=Shop_Commodity.com_id

  inner join Shop_Commodity_Type on Shop_Commodity.ct_name_fk=Shop_Commodity_Type.ct_name

  go

  create view view_Shop_User_Discount

  as

  select * from Shop_User_Discount

  inner join Shop_User on Shop_User_Discount.u_id_fk=Shop_User.u_id

  go

  create view view_Shop_Sale

  as

  select * from Shop_Sale

  inner join Shop_User on Shop_Sale.u_id_fk=Shop_User.u_id

  go

  create view view_Shop_Sale_Info

  as

  select * from Shop_Sale_Info

  inner join Shop_Sale on Shop_Sale_Info.sa_code_fk=Shop_Sale.sa_code

  inner join Shop_User on Shop_Sale.u_id_fk=Shop_User.u_id

  inner join Shop_Commodity on Shop_Sale_Info.com_id_fk=Shop_Commodity.com_id

  inner join Shop_Commodity_Type on Shop_Commodity.ct_name_fk=Shop_Commodity_Type.ct_name

  go

  create view view_Shop_Integral

  as

  select * from Shop_Integral

  inner join Shop_User on Shop_Integral.u_id_fk=Shop_User.u_id

  go

  create view view_Shop_UserExtension

  as

  select * from Shop_UserExtension

  inner join Shop_User on Shop_UserExtension.u_id_fk=Shop_User.u_id

版权声明:部分内容为互联网整合,文中观点不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,请发送邮件至举报,一经查实,本站将立刻删除。