DROP TABLE IF EXISTS c1;
DROP TABLE IF EXISTS b1;

DROP TABLE IF EXISTS c2;
DROP TABLE IF EXISTS b2;

DROP TABLE IF EXISTS a;

CREATE TABLE a (
	a_id INT AUTO_INCREMENT PRIMARY KEY
);

-- Tables b1 and b2 are identical, except that b1 declares its foreign key
-- separately, and b2 declares it inline.

-- Tables c1 and c2 are identical.

CREATE TABLE b1 (
	b_id INT AUTO_INCREMENT PRIMARY KEY,
	a_id INT NOT NULL,

	FOREIGN KEY (a_id) REFERENCES a (a_id)
);

CREATE TABLE c1 (
	a_id INT,
	b_id INT,

	PRIMARY KEY (a_id, b_id),
	FOREIGN KEY (a_id, b_id) REFERENCES b1 (a_id, b_id)
);



CREATE TABLE b2 (
	b_id INT AUTO_INCREMENT PRIMARY KEY,
	a_id INT NOT NULL REFERENCES a (a_id)
);

CREATE TABLE c2 (
	a_id INT,
	b_id INT,

	PRIMARY KEY (a_id, b_id),
	FOREIGN KEY (a_id, b_id) REFERENCES b2 (a_id, b_id)
);