List:General Discussion« Previous MessageNext Message »
From:mysql Date:March 20 2006 1:46pm
Subject:Re: Discussion: the efficiency in using foreign keys
View as plain text  
I'd also like to add that if you have a choice between doing 
something in the application logic vs. MySQL's SQL 
statements, then it is probably more efficient to use SQL 
statements, constructs and related functions, to get the job 
done, rather than in the application logic if possible.

Keith

In theory, theory and practice are the same;
in practice they are not.

On Mon, 20 Mar 2006, Martijn Tonies wrote:

> To: mysql@stripped
> From: Martijn Tonies <m.tonies@stripped>
> Subject: Re: Discussion: the efficiency in using foreign keys
> 
> Hi,
> 
> > This is a fundamental concept in RDBMS: the use of foreign keys in 
> > database design.
> > 
> > I'd just like to poll the community here, on whether it is a best 
> > practice, or practically essential to 'link' related tables by use of 
> > foreign keys.
> > 
> > For myself, I usually do all the validity checking when adding a new 
> > record that references a record id from another table. I understand that 
> > this may not be efficient because it becomes 2 database calls (and db 
> > calls are expensive in high-load environments).
> > 
> > What are the advantages/ disadvantages in using foreign keys? In MySQL, 
> > this means one cannot use MyISAM. Do you place a lot of triggers as well?
> 
> When it comes to referential constraints, the answer is simple:
> ALWAYS put them on the database.
> 
> Anyway who answers differently either never had to recover
> a database that was trashed by the lack of integrity constraints
> or has no ide what he's talking about.
> 
> Most probably, this statement will get me tons of e-mail again ;-)
> 
> Martijn Tonies
> Database Workbench - development tool for MySQL, and more!
> Upscene Productions
> http://www.upscene.com
> My thoughts:
> http://blog.upscene.com/martijn/
> Database development questions? Check the forum!
> http://www.databasedevelopmentforum.com
> 
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/mysql?unsub=1
> 
> 
Thread
Discussion: the efficiency in using foreign keysFoo Ji-Haw20 Mar
  • Re: Discussion: the efficiency in using foreign keysmysql20 Mar
    • Re: Discussion: the efficiency in using foreign keysFoo Ji-Haw20 Mar
  • Re: Discussion: the efficiency in using foreign keysMartijn Tonies20 Mar
    • Re: Discussion: the efficiency in using foreign keysmysql20 Mar
      • Re: Discussion: the efficiency in using foreign keysFoo Ji-Haw21 Mar