Skip to content

Mysql and Foreign Keys

If you ever try to use Foreign Keys in Mysql (of course, only the InnoDB tabletype allows this), don't forget, that the columns in both tables must have exactly the same definition.

If one column is bigint, the other also must be bigint. If one column is unsigned, the other table also needs to be an unsigned column. If you forget about this, mysql will give you a mystical error message (#1005 cannot create table), but it does not tell you, why it can't create the table.

Older versions of mysql (3.x, 4.0.x) also need an index on both columns in both tables, mysql since 4.1.something does create the index for you, if needed. This has the drawback, that you cannot reference char, varchar or text columns in mysql.

How can anyone get real work done with this *censored*?

  • Twitter
  • Bookmark Mysql and Foreign Keys at del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • Digg Mysql and Foreign Keys
  • Bloglines Mysql and Foreign Keys
  • Technorati Mysql and Foreign Keys
  • Fark this: Mysql and Foreign Keys
  • Bookmark Mysql and Foreign Keys at YahooMyWeb
  • Bookmark Mysql and Foreign Keys at Furl.net
  • Bookmark Mysql and Foreign Keys at reddit.com
  • Bookmark Mysql and Foreign Keys at blinklist.com
  • Bookmark Mysql and Foreign Keys at Spurl.net
  • Bookmark Mysql and Foreign Keys at Simpy.com
  • Bookmark Mysql and Foreign Keys at blogmarks
  • Bookmark Mysql and Foreign Keys with wists
  • wong it!
  • Bookmark using any bookmark manager!
  • Stumble It!
  • Identi.ca

Trackbacks

ads' corner on : Mysql and real trigger support

Show preview
I just answered a question in the usenet about triggers in Mysql and discovered something very scary:You can have only one trigger action time and event at a time for a table. So for example you can only have one "BEFORE INSERT" trigger.I only Comments ()

Comments

Display comments as Linear | Threaded

No comments

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.
To leave a comment you must approve it via e-mail, which will be sent to your address after submission.
Form options