Bluehost.com Web Hosting $6.95

newbie: error 1005, cannot create table

This is a discussion on newbie: error 1005, cannot create table within the MySQL Database forums, part of the Database Forums category; Hey MySql 5.0 When trying to create the Property table (see below) I get this error message: ERROR 1005 (...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-19-2007
Jeff
 
Posts: n/a
Default newbie: error 1005, cannot create table

Hey

MySql 5.0

When trying to create the Property table (see below) I get this error
message:
ERROR 1005 (HY000): Can't create table '.\demo\property.frm' (errno: 150)

Any suggestions to what I'm doing wrong here?

create table User (
UserId int unsigned not null auto_increment primary key,
UserForname varchar(50) not null
);

create table Property (
PropertyId int unsigned not null auto_increment primary key,
PropertyOwner int not null,
index idxPropertyOwner using hash (PropertyOwner),
foreign key (PropertyOwner) references User(UserId) on delete cascade
);


Reply With Quote
  #2 (permalink)  
Old 01-19-2007
Felix Geerinckx
 
Posts: n/a
Default Re: newbie: error 1005, cannot create table

"Jeff" <it_consultant1@hotmail.com.NOSPAM> wrote in news:1uidnR8xTp-
yJS3YRVnzvQ@telenor.com:


> When trying to create the Property table (see below) I get this error
> message: ERROR 1005 (HY000): Can't create table '.\demo\property.frm'
> (errno: 150)
>
> create table User (
> UserId int unsigned not null auto_increment primary key,
> UserForname varchar(50) not null
> );
>
> create table Property (
> PropertyId int unsigned not null auto_increment primary key,
> PropertyOwner int not null,
> index idxPropertyOwner using hash (PropertyOwner),
> foreign key (PropertyOwner) references User(UserId) on delete cascade
> );


Because of the foreign key constraint, the datatypes of User.UserId and
Property.PropertyOwner should be *exactly* the same.

Why are you using a hash-index? As far as I can tell, it's only supported
for MEMORY tables. And MEMORY tables cannot enforce referential
integrity.


--
felix
Reply With Quote
  #3 (permalink)  
Old 01-19-2007
Captain Paralytic
 
Posts: n/a
Default Re: newbie: error 1005, cannot create table


Jeff wrote:

> Hey
>
> MySql 5.0
>
> When trying to create the Property table (see below) I get this error
> message:
> ERROR 1005 (HY000): Can't create table '.\demo\property.frm' (errno: 150)
>
> Any suggestions to what I'm doing wrong here?
>
> create table User (
> UserId int unsigned not null auto_increment primary key,
> UserForname varchar(50) not null
> );
>
> create table Property (
> PropertyId int unsigned not null auto_increment primary key,
> PropertyOwner int not null,
> index idxPropertyOwner using hash (PropertyOwner),
> foreign key (PropertyOwner) references User(UserId) on delete cascade
> );


You have a mismatch on the field types. User.Userid is an unsigned int,
whereas Property.PropertyOwner is just int.

Reply With Quote
  #4 (permalink)  
Old 01-19-2007
Harald Fuchs
 
Posts: n/a
Default Re: newbie: error 1005, cannot create table

In article <1uidnR8xTp-yJS3YRVnzvQ@telenor.com>,
"Jeff" <it_consultant1@hotmail.com.NOSPAM> writes:

> Hey
> MySql 5.0


> When trying to create the Property table (see below) I get this error
> message:
> ERROR 1005 (HY000): Can't create table '.\demo\property.frm' (errno: 150)


> Any suggestions to what I'm doing wrong here?


> create table User (
> UserId int unsigned not null auto_increment primary key,
> UserForname varchar(50) not null
> );


> create table Property (
> PropertyId int unsigned not null auto_increment primary key,
> PropertyOwner int not null,
> index idxPropertyOwner using hash (PropertyOwner),
> foreign key (PropertyOwner) references User(UserId) on delete cascade
> );


In foreign keys, the types of the referencing and the referenced
column must be the same. You've got INT vs. INT UNSIGNED.
Reply With Quote
  #5 (permalink)  
Old 01-19-2007
Jeff
 
Posts: n/a
Default Re: newbie: error 1005, cannot create table


"Harald Fuchs" <hf1110x@protecting.net> wrote in message
news:puzm8fm9he.fsf@srv.protecting.net...
> In article <1uidnR8xTp-yJS3YRVnzvQ@telenor.com>,
> "Jeff" <it_consultant1@hotmail.com.NOSPAM> writes:
>
>> Hey
>> MySql 5.0

>
>> When trying to create the Property table (see below) I get this error
>> message:
>> ERROR 1005 (HY000): Can't create table '.\demo\property.frm' (errno: 150)

>
>> Any suggestions to what I'm doing wrong here?

>
>> create table User (
>> UserId int unsigned not null auto_increment primary key,
>> UserForname varchar(50) not null
>> );

>
>> create table Property (
>> PropertyId int unsigned not null auto_increment primary key,
>> PropertyOwner int not null,
>> index idxPropertyOwner using hash (PropertyOwner),
>> foreign key (PropertyOwner) references User(UserId) on delete cascade
>> );

>
> In foreign keys, the types of the referencing and the referenced
> column must be the same. You've got INT vs. INT UNSIGNED.


thanks to you all, it was the datatype mismatch


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 03:12 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0