I have attempted to create the following tables:
Customer:
CREATE TABLE Customer(customer_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
surname VARCHAR(15) NOT NULL,
forename VARCHAR(15) NOT NULL,
DOB TIMESTAMP NOT NULL,
phone_no VARCHAR(20) NOT NULL,
email_address VARCHAR(30),
postcode VARCHAR(15) NOT NULL,
PRIMARY KEY(customer_id)) ENGINE=INNODB;
When I attempt to create the 'Booking' table afterwards, I get an error
"ERROR 1005(HY000): can't create table 'Test.Booking' (errno:150)"
I checked the error online and found out that it was relating to the Foreign key connection that I attempted to make between the tables; which I will give below.
Booking:
CREATE TABLE Booking (booking_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
customer_id INT NOT NULL,
staying_from TIMESTAMP,
staying_until TIMESTAMP,
cost INT,
PRIMARY KEY(booking_id),
FOREIGN KEY(customer_id) REFERENCES Customer(customer_id)
ON UPDATE CASCADE ON DELETE RESTRICT) ENGINE=INNODB;