Reputation: 31
CREATE TABLE People
(
ID INT UNSIGNED AUTO_INCREMENT,
Company_Name VARCHAR(256) NOT NULL,
Predicted_Pos VARCHAR(20),
PRIMARY KEY (ID),
);
INSERT INTO People VALUES (1, 'Shujun Li', '3rd');
CREATE TABLE Driver
(
ID INT UNSIGNED AUTO_INCREMENT,
First_name VARCHAR(256) NOT NULL,
Last_name VARCHAR(256) NOT NULL,
Car_make VARCHAR(256) NOT NULL,
Car_model VARCHAR(256) NOT NULL,
People_ID INT UNSIGNED,
PRIMARY KEY (ID),
FOREIGN KEY(People_ID) REFERENCES People(ID)
);
INSERT INTO People VALUES (1, 'Shujun Li', 'bob', 'merc', 'benz', 1);
Upvotes: 0
Views: 50
Reputation: 162851
You have some circular references in your schema. The People
table depends on the Driver
table and the Driver
table depends on the People
table. You can never insert a record into one of the tables without having a row in the other first, an impossible, chicken n' egg situation. There are other examples of circular references in your schema. Remove all circular references from your schema.
Upvotes: 3