Trying to modify this which works:
CREATE TABLE customer
(
customer_id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(30),
PRIMARY KEY (customer_id)
) TYPE = INNODB;
CREATE TABLE customer_sales
(
transaction_id INT NOT NULL AUTO_INCREMENT,
amount INT,
customer_id INT NOT NULL,
PRIMARY KEY(transaction_id),
INDEX (customer_id),
FOREIGN KEY (customer_id) REFERENCES customer (customer_id)
) TYPE = INNODB;
Into this which fails. I thought maybe Transaction_ID was a reserved recognised syntax, but replacing OrderID with transaction_ID still no good.
CREATE TABLE company
(
CompanyID INT NOT NULL AUTO_INCREMENT,
CompanyName VARCHAR(30),
PRIMARY KEY (CompanyID)
) TYPE = INNODB;
CREATE TABLE orders
(
OrderID INT NOT NULL AUTO_INCREMENT,
OrderNumber INT,
CompanyID INT NOT NULL,
PRIMARY KEY(OrderID),
INDEX (CompanyID),
FOREIGN KEY (CompanyID) REFERENCES customer (CompanyID)
) TYPE = INNODB;
I was then thinking to add a third table on using foreign key OrderID, but progress shot down in flames. Regards
CREATE TABLE customer
(
customer_id INT NOT NULL AUTO_INCREMENT,
name VARCHAR(30),
PRIMARY KEY (customer_id)
) TYPE = INNODB;
CREATE TABLE customer_sales
(
transaction_id INT NOT NULL AUTO_INCREMENT,
amount INT,
customer_id INT NOT NULL,
PRIMARY KEY(transaction_id),
INDEX (customer_id),
FOREIGN KEY (customer_id) REFERENCES customer (customer_id)
) TYPE = INNODB;
Into this which fails. I thought maybe Transaction_ID was a reserved recognised syntax, but replacing OrderID with transaction_ID still no good.
CREATE TABLE company
(
CompanyID INT NOT NULL AUTO_INCREMENT,
CompanyName VARCHAR(30),
PRIMARY KEY (CompanyID)
) TYPE = INNODB;
CREATE TABLE orders
(
OrderID INT NOT NULL AUTO_INCREMENT,
OrderNumber INT,
CompanyID INT NOT NULL,
PRIMARY KEY(OrderID),
INDEX (CompanyID),
FOREIGN KEY (CompanyID) REFERENCES customer (CompanyID)
) TYPE = INNODB;
I was then thinking to add a third table on using foreign key OrderID, but progress shot down in flames. Regards