Answered step by step
Verified Expert Solution
Question
1 Approved Answer
However, it is generating an error Cannot add foreign key constraint. Can you please tell me what is wrong with both of the below codes?
However, it is generating an error "Cannot add foreign key constraint". Can you please tell me what is wrong with both of the below codes?
SQL Fiddle MySQL 5.6 Build Schema 1 Create Table employee ( 2 employee_id INTEGER NOT NULL, 3 first name varchar (30) NOT NULL, 4 last_name varchar (30) NOT NULL, 5 hire_date date NOT NULL, 6 job_title varchar (30) NOT NULL, 7 shop_id INTEGER NOT NULL, 8 PRIMARY KEY (employee_id), 9 FOREIGN KEY (shop_id) REFERENCES coffee shop (shop_id ) 10 ); Edit Fullscreen View Sample Fiddle * Cannot add foreign key constraint Browser E CClea SQL Fiddle [:] 1 Create Table coffee ( 2 3 4 MySQL 5.6 ) coffee_id INTEGER NOT NULL, Build Schema shop_id INTEGER NOT NULL, supplier_id INTEGER NOT NULL, 5 coffee_name varchar (30) NOT NULL, 6 prce_per_pound NUMERIC (5,2) NOT NULL, 7 PRIMARY KEY (coffee_id), 8 FOREIGN KEY (shop_id) REFERENCES coffee_shop(shop_id), FOREIGN KEY (supplier_id) REFERENCES supplier (supplier_id) 9 10 View Sample Fiddle Edit Fullscreen Browser * Cannot add foreign key constraint CClear [i]+
Step by Step Solution
★★★★★
3.45 Rating (152 Votes )
There are 3 Steps involved in it
Step: 1
1 The error Cannot add foreign key constraint is occurring because the table coffee shop has not bee...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started