I am trying to follow an example I found for creating two tables in a "related form" The code creates the two tables, however if I use PhpMYadmin to enter primary records in the first table, I get an error on trying to add a second record. Can someone advise whats wrong, thanks
CREATE TABLE customer
(
customer_id INT NOT NULL,
name VARCHAR(30),
PRIMARY KEY (customer_id)
) TYPE = INNODB;
CREATE TABLE customer_sales
(
transaction_id INT NOT NULL,
amount INT,
customer_id INT NOT NULL,
PRIMARY KEY(transaction_id),
INDEX (customer_id),
FOREIGN KEY (customer_id) REFERENCES customer (customer_id)
) TYPE = INNODB;
#1062 - Duplicate entry '0' for key 1
Also, is there an easy way to convert code into MySql_query lines. Thanks
CREATE TABLE customer
(
customer_id INT NOT NULL,
name VARCHAR(30),
PRIMARY KEY (customer_id)
) TYPE = INNODB;
CREATE TABLE customer_sales
(
transaction_id INT NOT NULL,
amount INT,
customer_id INT NOT NULL,
PRIMARY KEY(transaction_id),
INDEX (customer_id),
FOREIGN KEY (customer_id) REFERENCES customer (customer_id)
) TYPE = INNODB;
#1062 - Duplicate entry '0' for key 1
Also, is there an easy way to convert code into MySql_query lines. Thanks