Jump to content

[SOLVED] Cant make tables and FK not working


holz_bee

Recommended Posts

hello

 

i have been fiddling around with this for hours and got no where so i hope someon can help.

 

i have created a customer table

 

CREATE TABLE CUSTOMER
(Customer_ID VARCHAR(30) NOT NULL,
First_name CHAR (30) NOT NULL,
Last_name CHAR (30) NOT NULL,
E_mail VARCHAR (50),
Address_1 CHAR(30) NOT NULL,
Address_2 CHAR (30) NOT NULL,
Address_3 CHAR (30) NOT NULL,
Post_Code CHAR (6) NOT NULL,
Telephone VARCHAR(13),
Password VARCHAR (30) NOT NULL,
AVATAR VARCHAR (200),
Notes TEXT,
Constraint Pk_Customer Primary Key(Customer_ID))
TYPE = INNODB;

 

 

and it worked fine

then i made a second table

 

CREATE TABLE ORDER
(Order_ID CHAR(10) NOT NULL,
Customer_ID VARCHAR(30) NOT NULL,
Constraint Pk_Ord Primary Key(Order_ID),
INDEX ( Customer_ID ),
Constraint FK_Ord FOREIGN KEY (Customer_ID) REFERENCES CUSTOMER( Customer_ID ) ON DELETE CASCADE)
TYPE = INNODB;

 

and i wont add even if i delete the FK! i have then managed to make a table and tryed to alter it using

 

ALTER TABLE ORDER
ADD FOREIGN KEY (Customer_ID)
REFERENCES CUSTOMER(Customer_ID);

 

any help i will be so greatful! im using PHPmyadmin 2.9.2

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.