Error Creating Foreign Key Check Data Types Id
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack error creating foreign key check data types phpmyadmin Overflow the company Business Learn more about hiring developers or posting ads with us Stack
Error Creating Foreign Key On Name (check Data Types)
Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community
Error Creating Foreign Key On Table (check Data Types)
of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up MySQL Error creating foreign key on
#1452 - Cannot Add Or Update A Child Row: A Foreign Key Constraint Fails
seem to be having trouble setting up a Foreign Key between two of my tables. Here is the CREATE clause for each table: CREATE TABLE IF NOT EXISTS `dbname`.`CallRecord` ( `id` INT NOT NULL AUTO_INCREMENT, `user_id` INT NOT NULL, `city_id` INT NOT NULL, `created` DATETIME NULL, `timestamp` TIMESTAMP NULL, PRIMARY KEY (`id`), INDEX `user_id_fk_idx` (`user_id` ASC), INDEX `city_id_fk_idx` (`city_id` ASC), CONSTRAINT `user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `dbname`.`User` (`id`) ON DELETE RESTRICT ON UPDATE NO ACTION, CONSTRAINT `city_id_fk` FOREIGN KEY (`city_id`) REFERENCES `dbname`.`City` (`id`) ON DELETE RESTRICT ON UPDATE NO ACTION) ENGINE = InnoDB; And here is the other table: CREATE TABLE IF NOT EXISTS `dbname`.`DataCallAssoc` ( `id` INT NOT NULL AUTO_INCREMENT, `data_id` INT NOT NULL, `call_record_id` INT NOT NULL, PRIMARY KEY (`id`), INDEX `data_id_fk_idx` (`data_id` ASC), INDEX `call_record_id_fk_idx` (`call_record_id` ASC), CONSTRAINT `data_id_fk` FOREIGN KEY (`data_id`) REFERENCES `dbname`.`Data` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `call_record_id_fk` FOREIGN KEY (`call_record_id`) REFERENCES `dbname`.`CallRecord` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) ENGINE = InnoDB; The problem lies with the last CONSTRAINT of DataCallAssoc: CONSTRAINT `call_record_id_fk` FOREIGN KEY (`call_record_id`) REFERENCES `dbname`.`CallRecord` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION) I am getting this error: Error creating foreign key on call_record_id (check data types) Even when I create the table and foreign keys separately. Every other foreign keys work, and even other tables that point to CallRecord.id as a foreign key works. I also checked that CallRecord.id is the same as DataCallAssoc.call_record_id in terms of structure. mysql foreign-keys foreign-key-relationship share|improve this question asked Feb 11 '14 at 19:28 Koralarts 5201124 add a comment| 3 Answers 3 active oldest votes up vote 13 down vote The Error Creating Foreign Key...(check data types) error ALSO occurs if you al
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Error creating foreign key on
Search Username Password Remember Me? Register Lost Password? facebook google twitter rss Free Web Developer Tools Advanced Search Forum Databases MySQL Help Setting up Foreign keys Thread: Setting up Foreign keys Page 1 of 2 12 http://forums.devshed.com/mysql-help-4/setting-foreign-keys-520976.html Last Jump to page: Share This Thread Tweet This + 1 this http://dba.stackexchange.com/questions/142646/error-creating-foreign-key-on-check-data-types Post To Linkedin Subscribe to this Thread Subscribe to This Thread April 3rd, 2008,06:46 PM #1 msteudel View Profile View Forum Posts Visit Homepage Contributing User Devshed Novice (500 - 999 posts) Join Date Sep 2002 Location Seattle, U.S.A. Posts 715 Rep Power 15 Setting up Foreign keys Hi All, New to foreign key Foreign key stuff starting a new project and thought I would give it a whirl. I have two tables right now: users =========== id: int(10) email: varchar(255) cases =========== id: int(10) user_id: int(10) I want to create a foreign key from cases.user_id to the users.id. Both tables are InnoDB and I have created a index on user_id and I don't have any data in my tables. This is the code used error creating foreign to create the index: Code: ALTER TABLE `student_cases` ADD INDEX ( `user_id` ) WHen I try and create a foreign key using: Code: ALTER TABLE `student_cases` ADD FOREIGN KEY ( `user_id` ) REFERENCES `yah`.`users` ( `id` ) ON DELETE CASCADE ; I get the following error: Code: Error creating foreign key (check data types) : user_id * Note I'm using phpMyAdmin Thanks, Mark Faq Reply With Quote April 3rd, 2008,09:43 PM #2 r937 View Profile View Forum Posts Visit Homepage SQL Consultant Devshed Supreme Being (6500+ posts) Twitter Join Date Feb 2003 Location Toronto Canada Posts 27,591 Rep Power 4287 give us a hint the error message tells you it's a problem with the datatypes, but you haven't told us what the datatypes are rudy.ca | @rudydotca Buy my SitePoint book: Simply SQL Faq Reply With Quote April 4th, 2008,01:06 AM #3 msteudel View Profile View Forum Posts Visit Homepage Contributing User Devshed Novice (500 - 999 posts) Join Date Sep 2002 Location Seattle, U.S.A. Posts 715 Rep Power 15 Originally Posted by r937 give us a hint the error message tells you it's a problem with the datatypes, but you haven't
log in tour help Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Database Administrators Questions Tags Users Badges Unanswered Ask Question _ Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top Error creating foreign key on (check data types) up vote -1 down vote favorite Very weird problem. I need help, I can't figure out and I don't know how to trace the specific errors in phpmyadmin. I have 2 tables and I want to create FK between them. The first table is keywords: The second table is rankings: When I create FK on domain_id and keyword that working perfect,when I try to create on user_owe_id its says: Error creating foreign key on user_owe_id (check data types) Both columns are the same type and same name I don't know why its not working any hints please?. mysql sql phpmyadmin share|improve this question edited Jun 30 at 9:15 Joe Taras 434311 asked Jun 30 at 8:30 Ravivgg 1 1 Why do you need 2 FKs between the tables? What are their relationships? And what is the primary key of keywords? –ypercubeᵀᴹ Jun 30 at 8:45 1 Please post the SQL statement about creation of FK on user_owe_id –Joe Taras Jun 30 at 8:50 add a comment| active oldest votes Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook. Your Answer draft saved draft dis