Question

In: Computer Science

I get an error 1452 saying it cannot add or update my foreign key. is there...

I get an error 1452 saying it cannot add or update my foreign key. is there a way to fix this

Solutions

Expert Solution

Error Because you directly Inserting in Child Data you have to insert first in Parent Table otther wise it could not be inserted Here i gave you small Example same thing whith me and how i solved it

Create table Employee(eid int Primary Key,ename varchar(20),age INT,salary double);
desc Employee;
Create table Works(eid int,did int,pct_time int,CONSTRAINT Works_fk FOREIGN KEY (eid) REFERENCES Employee (eid));
desc Works;


/*Try to insert in directly Child but phasing problem */
insert into Works values(101,1001,100);

/*After inserting in Parent it we can be insert*/

insert into Employee values(101,'Andrew Fuller',40,50000);
Select * from Employee;
insert into Works values(101,1001,100);
Select * from Works;

if you still have any Problem regarding this question please comment and if you like my code please appreciate me by thumbs up thank you.........


Related Solutions

I keep getting the same error Error Code: 1822. Failed to add the foreign key constraint....
I keep getting the same error Error Code: 1822. Failed to add the foreign key constraint. Missing index for constraint 'test_ibfk_5' in the referenced table 'appointment', can you please tell me what is wrong with my code: -- Table III: Appointment = (site_name [fk7], date, time) -- fk7: site_name -> Site.site_name DROP TABLE IF EXISTS appointment; CREATE TABLE appointment (    appt_site VARCHAR(100) NOT NULL, appt_date DATE NOT NULL, appt_time TIME NOT NULL, PRIMARY KEY (appt_date, appt_time), FOREIGN KEY (appt_site)...
c++ I cannot get my operator+ to pass my test, it is failing on the first...
c++ I cannot get my operator+ to pass my test, it is failing on the first test, how would i convert my operator+ to use pointers and dynamic memory? Requirements: You CANNOT use the C++ standard string or any other libraries for this assignment, except where specified. You must use your ADT string for the later parts of the assignment. using namespace std; is stricly forbiden. As are any global using statements. Name the folder for this project: string (please...
I am doing a lab and I get this error message in my unittest: junit.framework.AssertionFailedError: Hint:...
I am doing a lab and I get this error message in my unittest: junit.framework.AssertionFailedError: Hint: matches() should have returned true when item matches the item passed into IdLookup constructor. Here is my code. What changes should be made? /** * This class is a lookup that matches items whose id matches exactly * a specified id, to be passed into the constructor when creating * the instance of the lookup. * * @author Franklin University * @version 2.0 */...
I cannot get this code to run on my python compiler. It gives me an expected...
I cannot get this code to run on my python compiler. It gives me an expected an indent block message. I do not know what is going on. #ask why this is now happenning. (Create employee description) class employee: def__init__(self, name, employee_id, department, title): self.name = name self.employee_id = employee_id self.department = department self.title = title def __str__(self): return '{} , id={}, is in {} and is a {}.'.format(self.name, self.employee_id, self.department, self.title)    def main(): # Create employee list emp1...
I can not get my Group Statistics or Indepependent Sample test to print...keep saying one group...
I can not get my Group Statistics or Indepependent Sample test to print...keep saying one group info is missing but it shows on other reports. How is the information entered on the SPSS grid. I want to see if I am enterring something wrong or it may be the software I just purchased 2 days ago. For Problem set 1 and 2 The independent-samples t-test. show each entry for both 1 and 2. Thanks
Please fix this python script, I keep getting a return outside function error and cannot get...
Please fix this python script, I keep getting a return outside function error and cannot get it to run: def caesar(plainText, shift):     cipherText = "" for char in plainText:     newChar = ord(char) + shift     if newChar > 128:       newChar = newChar % 128     finalChar = chr(newChar)     cipherText += finalChar return cipherText text = input("Enter a message: "); s = input("Enter the distance value: "); print (caesar(text, int(s)));
Java Counter Program I can't get my program to add the number of times a number...
Java Counter Program I can't get my program to add the number of times a number was landed on for my if statements for No12 through No2. My Code: import java.util.Scanner; import java.util.Random;    import java.lang.*;       public class Dice    {               public static void main(String[] args)        {            Scanner in = new Scanner(System.in);            int Continue = 1;            //randomnum = new Random();           ...
Could you double check my program? I cannot get it to run. If you could tell...
Could you double check my program? I cannot get it to run. If you could tell me any changes that need to be made as well show the output I would greatly appreciate it. LinkedList.java public class LinkedList { class Node{ int value; Node nextElement; public Node(int value) { this.value = value; this.nextElement = null; } } public Node first = null; public Node last = null; public void addNewNode(int element) { Node newValueNode = new Node(element); if(first == null)...
Why am I getting this error using 000webhost , but I do not get this error...
Why am I getting this error using 000webhost , but I do not get this error running XAMPP? Warning: Cannot modify header information - headers already sent by (output started at /storage/ssd2/006/14881006/public_html/test/index.php:1) in /storage/ssd2/006/14881006/public_html/test/index.php on line 8 Code is below. ******************************************************************************************************************** <!DOCTYPE html> <?php    //Determine if the submit button has been clicked to set the cookie name and value    if (isset($_POST['name'])){            $cookie_name = $_POST['name'];            $cookie_value = $_POST['value'];            setcookie($cookie_name, $cookie_value,...
Update: I provided an answer of my own (reflecting the things I discovered since I asked...
Update: I provided an answer of my own (reflecting the things I discovered since I asked the question). But there is still lot to be added. I'd love to hear about other people's opinions on the solutions and relations among them. In particular short, intuitive descriptions of the methods used. Come on, the bounty awaits ;-) Now, this might look like a question into the history of Ising model but actually it's about physics. In particular I want to learn...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT