> Believe me they knew what they where doing when they 
> choose not to implement this.

"I'm glad I live in rags - thank goodness I don't have to worry about
washing my clothes!!".

Enforcing foreign keys in your application can be pretty darn expensive, and
painful:

* You have to have a way of representing those "foreign keys" to some layer
of your application.
* Each modification would require your app to do a series of select()s *and
fetch the data to your app* where it would have to perform the referential
integrity checks.

(Unless you're talking about doing an "on the fly, sort of consistent but
maybe not" set of checks - sort of "not perfect, but good enough for
government work" foreign keys).

Of course, all that stuff above is what the actual database does as well,
when they do implement foreign keys properly (like Oracle does), but at
least it doesn't involve fetching data over to your application and
massaging it - the check is done entirely inside the database's own data
space, using its already optimized buffers.

[sql query database blah]

-----Original Message-----
From: Brandon Lewis [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 15, 2001 7:46 AM
To: Peter Pentchev; RAZAKA
Cc: [EMAIL PROTECTED]
Subject: RE: Create MULTIPLE TABLES ?


Foreign Keys are nice but they are costly items to use, best enforce the
reference in your business logic of your application. You can still join and
look up based on references but the database is not responsible for
enforcing the relationship. Believe me they knew what they where doing when
they choose not to implement this. Good Luck....

-----Original Message-----
From: Peter Pentchev [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 15, 2001 5:09 AM
To: RAZAKA
Cc: [EMAIL PROTECTED]
Subject: Re: Create MULTIPLE TABLES ?

On Tue, May 15, 2001 at 12:43:02PM +0200, RAZAKA wrote:
> I would like to create multiple tables in a database.
> HowTo Use REFERENTIAL INTEGRITY with MySQL ?
> May I use "FOREIGN KEY" or "REFERENCES"?
> Note: MySQL Release = 3.23.36
>
> Thanks for help :)

In short, you can't..

>From the MySQL manual (Reference >> CREATE TABLE):

   * The `FOREIGN KEY', `CHECK', and `REFERENCES' clauses don't
     actually do anything.  The syntax for them is provided only for
     compatibility, to make it easier to port code from other SQL
     servers and to run applications that create tables with references.

G'luck,
Peter

--
What would this sentence be like if pi were 3?

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to