/*==============================================================*/
/* DBMS name:      MySQL 5.0                                    */
/* Created on:     2012/12/10 16:29:31                          */
/*==============================================================*/
--
--创建数据库
--
drop database if exists shopping;
create database shopping;
use shopping;/*==============================================================*/
/* Table: T_UeserInfo                                           */
/*==============================================================*/
drop table if exists T_UeserInfo;
create table T_UeserInfo
(
   id                  int not null auto_increment primary key,
   userName              varchar(50) not null,
   userPwd               varchar(50) not null,
   createTime           datetime not null
);/*==============================================================*/
/* Table: T_BulletInfo                                          */
/*==============================================================*/
drop table if exists T_BulletInfo;
create table T_BulletInfo
(
   id                  int not null auto_increment primary key,
   title                varchar(50) not null,
   content              varchar(100) not null,
   userId                int not null,
   createTime           datetime not null 
);/*==============================================================*/
/* Table: T_CustomerInfo                                        */
/*==============================================================*/
drop table if exists T_CustomerInfo;
create table T_CustomerInfo
(
   id                  int not null auto_increment primary key,
   name                 varchar(50) not null,
   pwd                   varchar(50) not null,
   phone                 varchar(20) not null,
   address               varchar(50) not null,
   email                 varchar(20) not null,
   registerTime         datetime not null
);/*==============================================================*/
/* Table: T_GoodsType                                           */
/*==============================================================*/
drop table if exists T_GoodsType;
create table T_GoodsType
(
   typeId                int not null auto_increment primary key,
   typeName              varchar(50)  not null
);/*==============================================================*/
/* Table: T_GoodsInfo                                           */
/*==============================================================*/
drop table if exists T_GoodsInfo;
create table T_GoodsInfo
(
   GoodsId              int not null auto_increment primary key,
   typeId               int not null,
   goodsName             varchar(50) not null,
   price                double  not null,
   discount             double  not null,
   status               int not null  default 0,
   photo                varchar(50) not null
);/*==============================================================*/
/* Table: T_OrderInfo                                           */
/*==============================================================*/
drop table if exists T_OrderInfo;
create table T_OrderInfo
(
   orderId               int not null auto_increment primary key,
   customerId           int not null,
   goodsId              int not null,
   quantity             int not null,
   status               int default 0 not null,
   orderTime            datetime not null
);alter table T_BulletInfo add constraint bulletinfo_user foreign key( userId) references T_UeserInfo(id );
alter table T_GoodsInfo add constraint T_GoodsInfo_T_GoodsType foreign key( typeId) references T_GoodsType(id );
alter table T_OrderInfo add constraint OrderInfo_CustomerInfo foreign key( customerId) references T_CustomerInfo(id );以上sql语句在执行时,T_OrderInfo这张表建不了,报错,自己看一下应该是外键关联有问题,但是没有找到具体原因,请大神指导。。谢谢。
alter table T_OrderInfo add constraint OrderInfo_T_GoodsInfo foreign key( goodsId) references  T_GoodsInfo(id );