PHP电商购物车(一:建立数据表)
来源:互联网 发布:四维星瓷砖设计软件 编辑:程序博客网 时间:2024/04/29 13:33
PHP电商购物车功能———建立数据表
最近几天,简单完成了OOP学习阶段的购物车功能环节,将以前的一些知识都简单的运用了,总的来说,总结一下这个功能版块还是很有必要的。
购物车以当当网为范例,商品就以图书为例。
第一步:设计数据表。
模型图:
2.建表与表关系:
/*==============================================================*/
/* DBMS name: MySQL 5.0 */
/* Created on: 2016/7/4 20:54:17 */
/*==============================================================*/
/* DBMS name: MySQL 5.0 */
/* Created on: 2016/7/4 20:54:17 */
/*==============================================================*/
drop table if exists bookshop;
drop table if exists booktype;
drop table if exists myuser;
drop table if exists shopcar;
/*==============================================================*/
/* Table: bookshop 上图图书表 */
/*==============================================================*/
create table bookshop
(
b_id int not null auto_increment comment '图书ID',
b_name varchar(100) not null comment '图书名',
b_cover varchar(100) not null comment '封面图片(存储图片的文件路径)',
b_introduction varchar(1200) not null comment '图书简介',
b_author varchar(30) not null comment '作者',
b_press varchar(100) not null comment '出版社',
b_type int,
b_pressTime date not null comment '出版时间',
b_price decimal(10,2) not null comment '价格',
b_save int not null comment '库存',
primary key (b_id)
);
/* Table: bookshop 上图图书表 */
/*==============================================================*/
create table bookshop
(
b_id int not null auto_increment comment '图书ID',
b_name varchar(100) not null comment '图书名',
b_cover varchar(100) not null comment '封面图片(存储图片的文件路径)',
b_introduction varchar(1200) not null comment '图书简介',
b_author varchar(30) not null comment '作者',
b_press varchar(100) not null comment '出版社',
b_type int,
b_pressTime date not null comment '出版时间',
b_price decimal(10,2) not null comment '价格',
b_save int not null comment '库存',
primary key (b_id)
);
/*==============================================================*/
/* Table: booktype 上图书籍类型表 */
/*==============================================================*/
create table booktype
(
b_typeid int not null comment '类别ID',
b_type varchar(50) not null comment '类别',
primary key (b_typeid)
);
/* Table: booktype 上图书籍类型表 */
/*==============================================================*/
create table booktype
(
b_typeid int not null comment '类别ID',
b_type varchar(50) not null comment '类别',
primary key (b_typeid)
);
/*==============================================================*/
/* Table: myuser 上图用户表 */
/*==============================================================*/
create table myuser
(
u_id int not null auto_increment comment '用户ID',
u_name varchar(30) not null comment '用户名',
u_password varchar(20) not null comment '用户登录密码',
u_createtime datetime not null comment '用户注册时间',
u_isvalid tinyint not null comment '该用户身份是否有效',
primary key (u_id)
);
/* Table: myuser 上图用户表 */
/*==============================================================*/
create table myuser
(
u_id int not null auto_increment comment '用户ID',
u_name varchar(30) not null comment '用户名',
u_password varchar(20) not null comment '用户登录密码',
u_createtime datetime not null comment '用户注册时间',
u_isvalid tinyint not null comment '该用户身份是否有效',
primary key (u_id)
);
alter table myuser comment '用户表';
/*==============================================================*/
/* Table: shopcar 上图购物车 */
/*==============================================================*/
create table shopcar
(
u_id int not null comment '用户ID',
b_id int not null comment '图书ID',
s_num int not null comment '购买数量',
s_time datetime not null comment '采购时间',
primary key (u_id, b_id)
);
/* Table: shopcar 上图购物车 */
/*==============================================================*/
create table shopcar
(
u_id int not null comment '用户ID',
b_id int not null comment '图书ID',
s_num int not null comment '购买数量',
s_time datetime not null comment '采购时间',
primary key (u_id, b_id)
);
#外键关系
alter table booktype add constraint FK_b_type foreign key (b_typeid)
references bookshop (b_id) on delete restrict on update restrict;
references bookshop (b_id) on delete restrict on update restrict;
alter table shopcar add constraint FK_b_id foreign key (b_id)
references bookshop (b_id) on delete restrict on update restrict;
references bookshop (b_id) on delete restrict on update restrict;
alter table shopcar add constraint FK_u_id foreign key (u_id)
references myuser (u_id) on delete restrict on update restrict;
references myuser (u_id) on delete restrict on update restrict;
3. 说明。
在这个数据库中,只是为了简单实现购物车的功能,实际的购物车的数据库还会复杂的多,比如在每个表中都应该有状态列,时数据不直接删除,密码列的加密,至少还应有一张购买表记录购买信息,一张商品收藏表等等,还有很多细节就不一 一实现了,重点主要在使用PHP实现购物车方面。
0 0
- PHP电商购物车(一:建立数据表)
- PHP电商购物车(一:建立数据表)
- PHP电商购物车(二:封装数据库操作类)
- 电商独立购物车
- 购物车数据表
- PHP 建立大数据表代码
- android仿淘宝等电商购物车(Expandablelistview)
- 电商网站购物车实体
- 电商项目购物车基本实现
- 电商 购物车-订单-支付流程
- PHP语言建立数据库和数据表(乱码的解决)
- PHP语言建立数据库和数据表(完整版)
- 电商购物
- php购物车实现代码一例
- PHP-购物网站开发设计(一)
- SSH框架搭建电商系统之购物车表与购物车和商品库存问题(不用jquery)
- 电商平台的搭建(SpringMVC+SpringSecurity/Validation+Redis+MySQL+React)----购物车功能
- 电商(一)
- shadowsock使用注解
- OOP-----封装,继承,多态
- adb bash
- android-studio 2.2版本升级(踩坑)记
- 分布式、集群、负载均衡概念笔记
- PHP电商购物车(一:建立数据表)
- Android——Intent总结
- 2016.7.1
- UOJ 34 多项式乘法
- 来讲一下Enum
- 回文字符串
- UOJ 34 多项式乘法
- OOP-----类与对象对象
- 我真不黑博士