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
    )

  • 相关阅读:
    LeetCode "Palindrome Partition II"
    LeetCode "Longest Substring Without Repeating Characters"
    LeetCode "Wildcard Matching"
    LeetCode "Best Time to Buy and Sell Stock II"
    LeetCodeEPI "Best Time to Buy and Sell Stock"
    LeetCode "Substring with Concatenation of All Words"
    LeetCode "Word Break II"
    LeetCode "Word Break"
    Some thoughts..
    LeetCode "Longest Valid Parentheses"
  • 原文地址:https://www.cnblogs.com/cl94/p/9444536.html
Copyright © 2011-2022 走看看