【SQL开源代码栏目提醒】:文章导读:在新的一年中,各位网友都进入紧张的学习或是工作阶段。网学会员整理了SQL开源代码-warehouse.sql的相关内容供大家参考,祝大家在新的一年里工作和学习顺利!
# -----------------------------------------------------------------------
# bookstore
# -----------------------------------------------------------------------
drop database if exists bookstore;
CREATE database bookstore;
use bookstore;
# -----------------------------------------------------------------------
# userinfo
# -----------------------------------------------------------------------
drop table if exists userinfo;
CREATE TABLE userinfo
(
userid INT UNSIGNED NOT NULL AUTO_INCREMENT,
username VARCHAR (12) NOT NULL,
userpass
word VARCHAR (12) NOT NULL,
role INT UNSIGNED NOT NULL,
PRIMARY KEY(userid)
);
# -----------------------------------------------------------------------
# goods
# -----------------------------------------------------------------------
drop table if exists goods;
CREATE TABLE goods
(
goodid INT UNSIGNED NOT NULL AUTO_INCREMENT,
goodname VARCHAR (64) NOT NULL,
goodprice float(5,2) NOT NULL,
goodquality INT UNSIGNED NOT NULL,
goodpublish VARCHAR (128) NOT NULL,
PRIMARY KEY(goodid)
);
# -----------------------------------------------------------------------
# orders
# -----------------------------------------------------------------------
drop table if exists orders;
CREATE TABLE orders
(
orderid INT UNSIGNED NOT NULL AUTO_INCREMENT,
userid INT UNSIGNED NOT NULL,
goodid INT UNSIGNED,
type INT UNSIGNED NOT NULL,
goodname VARCHAR (64),
goodprice float(5,2),
goodquality INT UNSIGNED,
goodpublish VARCHAR (128),
PRIMARY KEY(orderid)
);
# -----------------------------------------------------------------------
# cart
# -----------------------------------------------------------------------
drop table if exists cart;
CREATE TABLE cart
(
userid INT UNSIGNED NOT NULL,
goodid INT UNSIGNED NOT NULL,
num INT UNSIGNED NOT NULL
);