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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.