Problems with simple Relational Database

Discussion in 'MySQL' started by cro91, May 26, 2012.

  1. #1
    I am trying to set up a database using foreign keys as show below. Every time I try to insert data into anime_info using something along the lines of...

    Test Data:


    It gives me an error. What I would like to be able to do is to store what genres relate to what anime and be able to show that data on the selected anime page, and maybe one day be able to search animes by genre, but as of now I can't figure out what I did wrong.

    I expected when I inserted the data into anime_info it would cascade the newly create "anime_id: 1" into the other tables. Is this wrong? What's the best way to go about what I am trying to do.

    Error:
    [COLOR=#000000][FONT=monospace]#1452 - Cannot add or update a child row: a foreign key constraint fails (`cro91_redplanetanime`.`anime_info`, CONSTRAINT `anime_info_ibfk_1` FOREIGN KEY (`anime_id`) REFERENCES `anime_genre` (`anime_id`) ON DELETE CASCADE ON UPDATE CASCADE) [/FONT][/COLOR]
    Code (markup):
    You can't relate two databases together. IE apples and oranges cant both be linked to one another only apples to oranges or oranges to apples. You cant do apples to oranges and oranges to apples.
     
    cro91, May 26, 2012 IP
  2. cro91

    cro91 Peon

    Messages:
    62
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Not everybody crowed the reply button at one time. I figured the answer out. Gonna remove my table info from the main post.
     
    cro91, May 27, 2012 IP