Answered step by step
Verified Expert Solution
Link Copied!

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 

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... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Databases questions