I'm trying to create a database that will keep information about users. Here is the strucure; I have 3 tables
1. is the users which keeps uid and login info(username and password)
2. is the users_info table which keep firstname, lastname mail age avatarid and gender there is column uid which foreign key is the ui from the users table where the login information is keeped. Avatarid is foreign key from another table which describe the avatar
3. Avatar - the table which will describe the avater.
The problem is that when i try to execute query to insert data i get this error:
Error Code: 1452. Cannot add or update a child row: a foreign key constraint fails (`soc_network`.`user_info`, CONSTRAINT `uid` FOREIGN KEY (`uid`) REFERENCES `users` (`uid`) ON DELETE NO ACTION ON UPDATE NO ACTION)
here is the query:
INSERT IGNORE INTO users(username, password) VALUES( 'username','passwd');
INSERT IGNORE INTO user_info(firstname, lastname, age, gender, email) VALUES('firstname','lastname','11', 'gender', 'mail')
any help is appriciated.
Aucun commentaire:
Enregistrer un commentaire