List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:September 3 1999 9:57am
Subject:Getting Errors Creating Tables
View as plain text  
>>>>> "Geocrawler" == Geocrawler com <archiver@stripped>
> writes:

Geocrawler> This message was sent from Geocrawler.com by "Richard"
> <rklein@stripped>
Geocrawler> Be sure to reply to that address.

Geocrawler> I am getting errors trying to create the following table:  

Geocrawler> CREATE TABLE Review (
Geocrawler> 	review_id tinyint(5) NOT NULL ZEROFILL AUTO_INCREMENT,
Geocrawler> 	user_id varchar(25) NOT NULL,
Geocrawler> 	PRIMARY KEY (review_id),
Geocrawler>                   FOREIGN KEY (user_id)
Geocrawler> )

Geocrawler> The mysql manual shows that foreign keys can be used.  I tried the
> statement without the FOREIGN KEY line and I still get an error on line 2.  Is there
> another way to delineate the attributes?

Geocrawler> Thanks,

Geocrawler> Richard			

Hi!

As you may have noted, the line number 2 is:

review_id tinyint(5) NOT NULL ZEROFILL AUTO_INCREMENT

(you have a also a bug in the foreign key definition, but it's
important to fix this problem first).

Try:

CREATE TABLE Review (review_id tinyint(5) ZEROFILL NOT NULL
AUTO_INCREMENT,user_id varchar(25) NOT NULL,PRIMARY KEY (review_id),
FOREIGN KEY (user_id) references other_table);


Note that the a foreign key definition as above doesn't really do
anything in any SQL server (except store the definition for later
retrieval).  In SQL you define table relationship when you do a join.

Regards,
Monty
Thread
Getting Errors Creating TablesGeocrawler.com3 Sep
  • Getting Errors Creating TablesMichael Widenius3 Sep
  • Re: Getting Errors Creating Tablessinisa3 Sep