Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Python, Lua and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Java, C, C++, Ruby, MySQL and Linux / Tomcat systems
spot the problem.....

Posted by Chris_Isaac (Chris Isaac), 28 August 2007

I'm trying to brush up on my mysql, The following is code I'm trying to follow, taken out of a book, but it fails when trying to create the 2nd table, I've gone through it but can't see whats wrong.  BTW I'm using mysql v 5.0.22 if this makes a difference.

I've cut out most of it but left the 1st table to fail (artists_events).

# phpMyAdmin MySQL-Dump
# version 2.2.6
# (download page)
# Host: localhost
# Generation Time: Aug 28, 2002 at 11:19 AM
# Server version: 3.23.51
# PHP Version: 4.0.4
# Database : `tunein`
# --------------------------------------------------------

# Table structure for table `artists`

CREATE TABLE `artists` (
 `artist_id` int(4) NOT NULL auto_increment,
 `artist_name` varchar(100) NOT NULL default '',
 PRIMARY KEY  (`artist_id`),
 UNIQUE KEY `artist_name` (`artist_name`)
) TYPE=InnoDB COMMENT='Musical performer or group.';
# --------------------------------------------------------

# Table structure for table `artists_events`

DROP TABLE IF EXISTS `artists_events`;
CREATE TABLE `artists_events` (
 `artist_event_id` int(4) NOT NULL auto_increment,
 `artist_id` int(4) NOT NULL default '0',
 `event_id` int(4) NOT NULL default '0',
 PRIMARY KEY  (`artist_event_id`),
 KEY `artist_id` (`artist_id`),
 KEY `event_id` (`event_id`),
 FOREIGN KEY (`artist_id`) REFERENCES `tunein.artists` (`artist_id`),
 FOREIGN KEY (`event_id`) REFERENCES `` (`event_id`)
) TYPE=InnoDB COMMENT='Lookup table for artists and events where they perform.';
# --------------------------------------------------------

Posted by Chris_Isaac (Chris Isaac), 29 August 2007
Ok, kinda sorted the problem out, even got the data in to the tables

Question though, When using Foreign Keys and References, why does the data need to be put into the tables in a particular order?

Hope the question makes sense, not too sure if I'm asking the right one  

Posted by admin (Graham Ellis), 30 August 2007
Not sure either, Chris ... my mind's not in SQL mode at the moment - sorry.  Come back and nag me in a couple of days if you need a further bit of help to move practically forward or an answer on the side issue raised.

Weren't you supposed to be coming to see us some time?   Next couple of weejends are frannkly busied out but it then starts getting much more do-able from Mid September!

Posted by Chris_Isaac (Chris Isaac), 30 August 2007
Thanks Graham, Yes believe me we still want to come down and catch up, perhaps a curry as well

Will bounce some dates off the boss wife and see when we can make it.

Look forward to seeing you soon.



This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2018: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01225 708225 • FAX: 01225 793803 • EMAIL: • WEB: • SKYPE: wellho