DROP TABLE IF EXISTS members;
CREATE TABLE members (
Member_ID char(10) NOT NULL default '',
Provider_ID char(10) NOT NULL default '',
First_Name varchar(30) NOT NULL default '',
Middle_Initial char(1) NOT NULL default '',
Last_Name varchar(40) NOT NULL default '',
Address varchar(100) NOT NULL default '',
City varchar(100) NOT NULL default '',
State char(2) NOT NULL default '',
Zip varchar(5) NOT NULL default '',
PRIMARY KEY (Member_ID),
FOREIGN KEY (PROVIDER_ID) REFERENCES PROVIDER(PROVIDER_ID)
) ;
DROP TABLE IF EXISTS provider;
CREATE TABLE provider (
Provider_ID char(10) NOT NULL default '',
Provider_Name varchar(50) NOT NULL default '',
Address varchar(100) NOT NULL default '',
City varchar(100) NOT NULL default '',
State char(2) NOT NULL default '',
Zip char(5) NOT NULL default '',
PRIMARY KEY (Provider_ID)
) ;
DROP TABLE IF EXISTS procedures;
CREATE TABLE procedures (
Procedure_ID char(10) NOT NULL default '',
Doctor_ID char(10) NOT NULL default '',
Member_ID char(10) NOT NULL default '',
Procedure_Type_ID char(10) NOT NULL default '',
Procedure_Name varchar(50) NOT NULL default '',
Cost int(10) NOT NULL default '0',
Date_Executed date NOT NULL default '2000-01-01',
PRIMARY KEY(Procedure_ID),
FOREIGN KEY(DOCTOR_ID) REFERENCES DOCTOR(DOCTOR_ID),
FOREIGN KEY(MEMBER_ID) REFERENCES MEMBER(MEMBER_ID),
FOREIGN KEY(PROCEDURE_TYPE_ID) REFERENCES PROCEDURE_TYPE(PROCEDURE_TYPE_ID)
) ;
DROP TABLE IF EXISTS procedure_type;
CREATE TABLE procedure_type (
Procedure_Type_ID char(10) NOT NULL default '',
Procedre_Type_Name varchar(50) NOT NULL default '',
Procedure_Description varchar(255) NOT NULL default '',
Procedure_ID char(10) NOT NULL default '',
PRIMARY KEY(Procedure_Type_ID),
FOREIGN KEY(PROCEDURE_ID) REFERENCES PROCEDURES(PROCEDURE_ID)
) ;
DROP TABLE IF EXISTS doctor_type;
CREATE TABLE doctor_type (
Type_ID char(10) NOT NULL default '',
Type_Name varchar(50) NOT NULL default '',
Type_Description varchar(255) NOT NULL default '',
PRIMARY KEY(Type_ID)
) ;
DROP TABLE IF EXISTS doctor;
CREATE TABLE doctor (
Doctor_ID char(10) NOT NULL default '',
Type_ID char(10) NOT NULL default '',
Doctor_Name varchar(50) NOT NULL default '',
Address varchar(100) NOT NULL default '',
City varchar(100) NOT NULL default '',
State char(2) NOT NULL default '',
Zip char(5) NOT NULL default '',
PRIMARY KEY(Doctor_ID),
FOREIGN KEY(TYPE_ID) REFERENCES DOCTOR_TYPE(TYPE_ID)
) ;
错误 1005 (HY000): 无法创建表 'thunderhawk.members' (errno: 150)
有任何想法吗?
我知道这是一个外键问题。我似乎遵循外键语法......