我有这些表,但只设法创建
- 保险_保单_类型
- 历史_时代
- 地区
- 参考
- 组织
- 地理_区域
其余的都给我错误,例如,
"Cant create table" on Loan_Item,
"Reference_Id dont exist" on Historical_Era_Reference
"error 1064 (4200)" on Loan
CREATE TABLE Insurance_Policy_Type (
Insurance_Policy_Type_Id INT (4),
Insurance_Policy_Type_Name VARCHAR (30),
PRIMARY KEY (Insurance_Policy_Type_Id));
CREATE TABLE Historical_Era (
Historical_Era_Id INT (4),
Historical_Era_Name VARCHAR (30),
PRIMARY KEY (Historical_Era_Id));
CREATE TABLE Reference (
Reference_Id INT (4),
Reference_Name VARCHAR (30),
Author VARCHAR (30),
PRIMARY KEY (Reference_Id));
CREATE TABLE Region (
Region_Id INT (4),
Region_Name VARCHAR (30),
PRIMARY KEY (Region_Id));
CREATE TABLE Organisation (
Organisation_Id INT (4),
Organisation_Name VARCHAR (30),
PRIMARY KEY (Organisation_Id));
CREATE TABLE Items (
Item_Id INT (4),
Item_Name VARCHAR (30),
Description VARCHAR (30),
Insurance_Policy_Type_Id INT (4),
Geo_Area_Id INT (4)
PRIMARY KEY (Item_Id),
FOREIGN KEY (Insurance_Policy_Type_Id) REFERENCES Insurance_Policy_Type(Insurance_Policy_Type_Id),
FOREIGN KEY (Geo_Area_Id) REFERENCES Geographic_Area(Geo_Area_Id));
CREATE TABLE GeoArea_HistEra (
Geo_Area_Id INT (4),
Historical_Era_Id INT (4),
FOREIGN KEY (Geo_Area_Id) REFERENCES Geographical_Area(Geo_Area_Id)),
FOREIGN KEY (Historical_Era_Id) REFERENCES Historical_Era(Historical_Era_Id));
CREATE TABLE Historical_Era_Reference (
References_Id INT (4),
Historical_Era_Id INT (4),
FOREIGN KEY (Reference_Id) REFERENCES Reference (Reference_Id),
FOREIGN KEY (Historical_Era_Id) REFERENCES Historical_Era (Historical_Era_Id));
CREATE TABLE Loan_Item (
Item_Id INT (4),
Loan_Id INT (4),
FOREIGN KEY (Item_Id) REFERENCES Items(Item_Id),
FOREIGN KEY (Loan_Id) REFERENCES Loan(Loan_Id));
CREATE TABLE Geographic_Area (
Geo_Area_Id INT (4),
Geo_Area_Name VARCHAR (30),
Region_Id INT (4),
PRIMARY KEY (Geo_Area_Id),
FOREIGN KEY (Region_Id) REFERENCES Region (Region_Id));
CREATE TABLE Loan (
Loan_Id INT (4),
Item_Id INT (4)
Organisation_Id INT(4)
Loan_Start DAY,
Loan_End DAY
FOREIGN KEY (Organisation_Id) REFERENCES Organisation (Organisation_Id),
FOREIGN KEY (Item_Id) REFERENCES Items (Item_Id));