foreign key

MySQL syntax examples - create table, primary key, foreign key

Just a quick note here today that if you need some example MySQL database tables, you can use these. I created them for some experiments I ran last night. They show the MySQL create table, primary key, and foreign key syntax:

SQLite foreign key examples

SQLite foreign keys FAQ: Can you show me how to define foreign keys in a SQLite database table design?

The SQLite database does support foreign keys, and its foreign key syntax is similar to other databases. Here’s a quick SQLite foreign key example.

MySQL foreign key examples (How to define foreign keys in MySQL)

MySQL foreign key FAQ: How do I define a foreign key in MySQL?

Answer: Here's a quick example of how I typically define a foreign key in MySQL.

Diving right into an example, here's the definition for a MySQL database table named nodes that I will link to from a second table:

MySQL drop table and foreign keys tip - the FOREIGN_KEY_CHECKS variable

MySQL “DROP TABLE” FAQ: Help, my MySQL database tables have a lot of foreign keys, and as a result it's a pain to use the MySQL DROP TABLE command in my scripts; they keep failing because of all the foreign keys. Is there something I can do to work around this DROP TABLE foreign keys problem?

Show MySQL foreign keys with the "show create table" command

I got a really brutal looking error message from Spring and MySQL yesterday. I've been working on a Java-based web interface for Nagios for a client, and I ran into an error message that basically says "Cannot add or update a child row: a foreign key constraint fails". If you like ugly, gruesome error messages here is the full-blown error: