I need help trying to figure out the code for these two tables. I am using SQL Fiddle.
Donut Order ID (PK) INT (10)
Customer ID(FK) INT (10)
Order Date DATETIME (6)
Special Notes VARCHAR (30)
Donut Order ID (PK)(FK) INT (10)
Donut ID (PK)(FK) INT (10)
Qty INT (10)
I have tried your schema and there schema and it is working fine for me
Try this to create schema for OrderTable with foreign key reference
CREATE TABLE `OrderTable` ( `donutorderid` varchar(10) NOT NULL, `customerid` varchar(10) NOT NULL, `oderdate` datetime(6) NOT NULL, PRIMARY KEY (`donutorderid`), CONSTRAINT `ordertable_ibfk_1` FOREIGN KEY (`customerid`) REFERENCES `Customer` (`customer_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
So there was a small error in your ALTER command
in Customer table the name of field is customer_id and not customerid.
ALTER TABLE OrderTable ADD INDEX checks (customerid), ADD CONSTRAINT checks FOREIGN KEY (customerid) REFERENCES Customer (customer_id);
SQLfiddle for same:- http://sqlfiddle.com/#!9/0eb295