LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   mySQL Foreign key that will not be constrained (http://www.linuxquestions.org/questions/linux-server-73/mysql-foreign-key-that-will-not-be-constrained-907473/)

Mogget 10-10-2011 05:18 PM

mySQL Foreign key that will not be constrained
 
I realize that linuxquestions might be the wrong place to ask this question but I will try anyway.

I am making a simple database that will be populated with data from a perl script. The tables are created and they work fine unless for one thing. I can create rows in the url table with nickids that does not exist in people even though I use the constraint attribute. Anyone have an ide why this is so?

*edit* I pasted a new version of the original code that will not be lost after a couple of days *edit*
http://pastebin.com/DJQ4BtL6

PS, I wrote this by hand so there might be writing errors in the code.

Mogget 10-11-2011 06:01 AM

I just found the solution together with some of my classmates. It seems mySQL does not support foreign keys by default so you have to use innodb. You do that by adding the line ENGINE=InnoDB at the end of each table creation.

Here is a complete copy of the changes.
http://pastebin.com/hJCSBArj


All times are GMT -5. The time now is 05:52 AM.