zoukankan      html  css  js  c++  java
  • 商城一 之设计数据库

    商城数据表设计

    php think make:model index/user
    php think make:model index/admin
    php think make:model index/goodsType
    php think make:model index/goods
    php think make:model index/goodsAttr
    php think make:model index/goodsVal
    php think make:model index/cart
    php think make:model index/orders
    php think make:model index/ordersDetail


    用户:

    user(用户表)
    id
    name
    password
    email
    create_date ---创建日期
    login_date ---上次登陆日期
    credit ---信用积分,买一块钱一分
    status ---是否启用,默认1

    admin(管理员表)
    id
    name
    password
    email
    role ---管理员角色(三种角色, admin,1 :超级管理员,2:普通管理员)
    admin:所有权限 1:所有权限(但不能操作超级管理员) 2:只能管理后台
    create_date ---创建日期
    login_date ---上次登陆日期
    status ---是否启用,默认1
    ------------------------------------------------------------------------------------
    商品:
    goodsType(商品类型)
    id
    name ---商品类型的名称

    goods(商品表)
    id
    name
    img ---缩略图
    desc ---商品描述
    price ---价格
    status ---是否启用,默认1
    goodsType_id ---商品类型id【外键】

    goodsAttr(商品属性,不同类型的商品有不同的属性)
    id
    name ---属性名
    goodsType_id ---商品类型id【外键】

    goodsVal(商品属性值)
    id
    value ---属性值
    goodsAttr_id ---商品属性id【外键】
    goods_id ---对应的商品

    ----------------------------------------------------------------------------------
    购物车:
    cart(购物车)
    id
    goods_id ---对应的商品id【外键】
    user_id ---对应的用户id【外键】
    count ---数量

    -----------------------------------------------------------------------------------
    订单表:
    orders(订单)
    id
    create_date ---创建日期
    user_id ---创建人id【外键】
    status ---订单状态(6:已退款,5:已取消,1:未付款,2:已付款,3:已发货,4:已签收)
    money ---订单总价(浮点数)

    ordersDetail(订单详情)
    id
    orders_id ---对应的订单id【外键】
    goods_id ---对应的商品id【外键】
    count ---数量
    money ---价格

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


    user(用户表)

    create table user(
    id int auto_increment primary key,
    name varchar(20) not null,
    password varchar(50) not null,
    email varchar(50),
    create_date int(11),
    login_date int(11),
    credit int(11) default 0,
    status boolean default 1
    )

    admin(管理员表)

    create table admin(
    id int auto_increment primary key,
    name varchar(20) not null,
    password varchar(50) not null,
    email varchar(50),
    role boolean default 1,
    create_date int(11),
    login_date int(11),
    status boolean default 1
    )

    goodsType(商品类型)
    create table goodsType(
    id int auto_increment primary key,
    name varchar(20) not null unique,
    )

    goods(商品表)
    create table goods(
    id int auto_increment primary key,
    name varchar(50) not null,
    price decimal(11,2) not null,
    img varchar(100) not null,
    brand varchar(20) not null,
    status boolean default 1,
    goodsType_id int
    )

    goodsAttr(商品属性,不同类型的商品有不同的属性)
    create table goodsAttr(
    id int auto_increment primary key,
    name varchar(20) not null unique,
    goodsType_id int
    )

    goodsVal(商品属性值)
    create table goodsVal(
    id int auto_increment primary key,
    value varchar(20) not null,
    goodsAttr_id int,
    goods_id int
    )

    cart(购物车)
    create table cart(
    id int auto_increment primary key,
    goods_id int,
    user_id int,
    count int
    )

    orders(订单)
    create table orders(
    id int auto_increment primary key,
    create_date int(11),
    user_id int,
    status boolean default 1 not null,
    money decimal(11,2) not null
    )

    ordersDetail(订单详情)
    create table ordersDetail(
    id int auto_increment primary key,
    orders_id int,
    goods_id int,
    count int not null,
    money decimal(11,2) not null
    )

  • 相关阅读:
    Ubuntu下Sublime Text 2优化配置
    Ubuntu14.04 设置wifi热点
    我是如何从程序小白成为码农的
    eclipse 配置黑色主题
    经典面试题(1):统计整数中1的个数
    Matlab一个错误引发的血案:??? Error using ==> str2num Requires string or character array input.
    折腾到死:matlab7.0 安装
    VMware 与Ubuntu通过samba服务器共享文件
    大自然的搬运工:Ubuntu环境下gedit的一些个简单配置
    UML(Unified Model Language)统一建模语言
  • 原文地址:https://www.cnblogs.com/cl94/p/9444536.html
Copyright © 2011-2022 走看看