0

So I've already looked here and I've tried two of the solutions but it didn't work for me = I have hard time understanding this error. I'm kind of new to databases and MySQL in general.

You can find my database right here. I populate the tables with scripts in cmdspace_lostmac queries/ folder.

What I did:

  1. Designed DB via ERR diagram via MySQL Workbench
  2. Exported the DB as .sql script (file cmdspace_lostmac.sql)
  3. Ran the script on my local server on my machine (no errors)
  4. Ran all the other scripts except model.sql (no errors so far)
  5. Then it gives me error 1452

The model.sql file contains this script:

# desktops
insert into model(category_id, product_name, product_identifier, year_released, size_id, color_id, CPU_id, GPU_id, ext_link)
values(2, 'iMac Retina 5K Late 2014', 'iMac15,1', 2014, 18, 1, 43, 41, 'http://www.everymac.com/systems/apple/imac/specs/imac-core-i5-3.5-27-inch-aluminum-retina-5k-late-2014-specs.html');

# laptops 
insert into model(category_id, product_name, product_identifier, year_released, size_id, color_id, CPU_id, GPU_id, ext_link)
values(1, 'Macbook Air Mid 2012', 'MacBookAir5,2', 2012, 9, 1, 138, 35, 'http://www.everymac.com/systems/apple/macbook-air/specs/macbook-air-core-i5-1.8-13-mid-2012-specs.html');

# iphones
insert into model(category_id, product_name, product_identifier, year_released, color_id, size_id, drive_id, ext_link)
values (3, 'iPhone 6 Plus', 'iPhone7,1', 2014, 4, 4, 5, 'http://www.everymac.com/systems/apple/iphone/specs/apple-iphone-6-plus-a1522-5.5-inch-gsm-north-america-specs.html');

Note: When I run SET foreign_key_checks = 0;, run the script and then set back to SET foreign_key_checks = 1; I can do this. But obviously I would need to disable the check everytime I need to update database. That's obviously bad design.

Community
  • 1
  • 1
user3056783
  • 2,265
  • 1
  • 29
  • 55

0 Answers0