If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > InnoDB

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-25-05, 21:01
ManhQuynh ManhQuynh is offline
Registered User
 
Join Date: Feb 2005
Location: Sweden
Posts: 45
InnoDB

Hi,

What is the difference between InnoDB and MyISAM?

My situation is that I have two tables where I join them. What I need to do is when I delete a record on the "primary" (do you call it that?) table, the other table's records, that are linked to the primary tables record, should be deleted aswell.

I've read in another thread that you can do that in MySQL, but only on InnoDB tables. I have tried ON DELETE CASCADE, but I get the message: Error creating the foreign key.
Check these information before creating a foreign key
-both tables should have an Index for the columns specified
-the size and the signedness of integer types has to be the same
-defined ON DELETE/ON UPDATE SET TO NULL but the column is defined as NOT NULL.

I'm using DBManager Professional 2.3.0, freeware edition.

My tables:
CREATE TABLE `tblindexbyobject`
(
`indexId` INTEGER (255) UNSIGNED NOT NULL DEFAULT 0,
`adId` INTEGER (255) UNSIGNED NOT NULL DEFAULT 0
) TYPE=InnoDB

CREATE TABLE `tblobject`
(
`adId` INTEGER (255) UNSIGNED NOT NULL AUTO_INCREMENT ,
`adSubject` varchar (255),
`adBody` longtext NOT NULL ,
`adDate` DATE,
PRIMARY KEY (adId)
) TYPE=InnoDB

Hope you can help me.
Reply With Quote
  #2 (permalink)  
Old 02-25-05, 21:20
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
first of all, you have to declare an index on the adid column in the tblindexbyobject table

then you have to declare a foreign key in the tblindexbyobject table on adid referencing table tblobject (adid) with ON DELETE CASCADE

by the way, did you declare your integers as INTEGER(255), or was it DBManager Professional 2.3.0? because 255 is silly, INTEGER only goes up to approx 2 billion (10 digits)
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 02-25-05, 22:10
ManhQuynh ManhQuynh is offline
Registered User
 
Join Date: Feb 2005
Location: Sweden
Posts: 45
Thank you, it worked!

And no, it was silly me who thought that I could set integer to 255.

Can I now use rollback with those InnoDB tables? How do I do that?

What is the difference between InnoDB and MyISAM?

//M
Reply With Quote
  #4 (permalink)  
Old 02-25-05, 22:33
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
sorry, can't help you any further, i've never done rollback, and i don't know any mysql internals
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 02-25-05, 22:48
ManhQuynh ManhQuynh is offline
Registered User
 
Join Date: Feb 2005
Location: Sweden
Posts: 45
Thumbs up

You have allready helped me enough.
I'm on to it by searching on google.

//M
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 On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On