1
Sakul
Foreign key in InnoDB
  • 2008/7/27 18:44

  • Sakul

  • Just popping in

  • Posts: 3

  • Since: 2008/7/27


Hi.
I have problem with foreign key. This is my code:
CREATE TABLE product (category INT NOT NULL
                      
id INT NOT NULL,
                      
price DECIMAL,
                      
PRIMARY KEY(categoryid)) ENGINE=INNODB;
                      
CREATE TABLE customer (id INT NOT NULL,
                       
PRIMARY KEY (id)) ENGINE=INNODB;
                       
CREATE TABLE product_order (no INT NOT NULL AUTO_INCREMENT,
                            
product_category INT NOT NULL,
                            
product_id INT NOT NULL,
                            
customer_id INT NOT NULL,
                            
PRIMARY KEY(no),
                            
INDEX (product_categoryproduct_id),
                            
FOREIGN KEY (product_categoryproduct_id)
                              
REFERENCES product(categoryid)
                              
ON UPDATE CASCADE ON DELETE RESTRICT,
                            
INDEX (customer_id),
                            
FOREIGN KEY (customer_id)
                              
REFERENCES customer(id)) ENGINE=INNODB;


When I install my module with this sql file, XOOPS show error: Can't create table 'xoops_databaze.xoops_product_order' (errno: 150)

Please for advice.

Thanks.

2
Sakul
Re: Foreign key in InnoDB
  • 2008/7/29 10:03

  • Sakul

  • Just popping in

  • Posts: 3

  • Since: 2008/7/27


Please for help.

3
Sakul
Re: Foreign key in InnoDB
  • 2008/7/30 15:47

  • Sakul

  • Just popping in

  • Posts: 3

  • Since: 2008/7/27


Error was in the table prefix in the definition of foreign keys.

Login

Who's Online

293 user(s) are online (208 user(s) are browsing Support Forums)


Members: 0


Guests: 293


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits