» Quick Links
You can make money on these forums
We Share profits with you
Google
Google Adsense
Google Adwords
YPN
Yahoo
MSN Search
Web Directories
Web Hosting
Web Hosting Offers
Hosting News
Suggestions
Link Building
Domain Names
PHP Forums
MySQL Forums
» More Links
OSP News
Reseller Hosting
Shared Hosting
Dedicated Servers
Google Adsense
Search Engine Marketing
Link Development
Affiliate Marketing


» Advertising
Multiple DC PR Check

Free SEO Tools


Go Back   Webmaster Forums > Website Developement / Programming > MySQL Forums

MySQL Forums Share Your Ideas and Tips about MYSQL. Ask questions about MYSQL. Table Design and Much More...

Reply
 
Thread Tools Display Modes
  #1  
Old 08-09-2006, 11:13 AM
ihento ihento is offline
OSP Starters
 
Join Date: Aug 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
ihento is on a distinguished road
Default refrential integrity

Hi mates

I have been using mysql for two years, but am trapped in this liltle problem, please don't laugh.

What I wanna do is simply create two tables, such that a field in one table is a foreign key in the other.

i.e.
create table a ( val1 int primary key )
create table b ( val1 int, val2 int, primary key (val1), foriegn key (val2) references a(val1) ).

What I want is that table b must not have any value in val2 that is not present in table a. and one a value from table a is deleted, all the corresponding values from table b are automatically deleted !!!

Thanks for replying -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Revenue Sharing Ads ( ?):
  #2  
Old 08-09-2006, 11:15 AM
looney looney is offline
OSP Starters
 
Join Date: Aug 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
looney is on a distinguished road
Default

That syntax looks okay, but val2 needs to have an index, and both tables have to be InnoDB.

This should help you
Bye -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Reply


Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
referential integrity.... Austinn MySQL Forums 1 11-08-2006 04:48 AM
Quality, Reliability and Integrity! WebzPro! Macie WebHosting Offers 0 08-03-2006 01:06 PM
Privacy Networks Launches Email Integrity Suite outsourcingplans Web Hosting Industry 0 02-08-2006 07:24 PM


All times are GMT. The time now is 12:26 PM.