Just wondering if anyone who knew the answer to this might have missed it 
before -- sorry to keep nagging but I really need to find out how, or 
whether, you can determine which fields in a table are foreign keys 
referencing another table.

Is it not possible to determine, after a table is created, what fields in 
the table are foreign keys?  For a MyISAM table (where referential 
integrity is not enforced), is this information even retained?

         -Bennett

At 04:53 AM 11/13/2001 -0800, you wrote:
>I created the "persons" and "shirts" tables as described in the MySQL 
>tutorial:
>
>http://www.mysql.com/doc/e/x/example-Foreign_keys.html
>
>such that the "owner" field in shirts is a foreign key referencing the 
>"persons" table.  However, "describe shirts" does not indicate that the 
>field is a foreign key: (may have to widen mail viewer window to view the 
>following table)
>
>mysql> describe shirts;
>+-------+---------------------------------------------+------+-----+---------+----------------+
>| Field | Type                                        | Null | Key | 
>Default | Extra          |
>+-------+---------------------------------------------+------+-----+---------+----------------+
>| id    | smallint(5) unsigned                        |      | PRI | 
>NULL    | auto_increment |
>| style | enum('t-shirt','polo','dress')              |      |     | 
>t-shirt |                |
>| color | enum('red','blue','orange','white','black') |      |     | 
>red     |                |
>| owner | smallint(5) unsigned                        |      |     | 
>0       |                |
>+-------+---------------------------------------------+------+-----+---------+----------------+
>4 rows in set (0.00 sec)
>
>How do I find out which fields are foreign keys?
>
>For that matter, in a MyISAM table, what difference does it make whether 
>you specify that a given field is a foreign key referencing another table 
>-- as opposed to just an integer field with the same data type as the key 
>field of another table?  Since referential integrity is not enforced with 
>MyISAM tables, does it not make any difference whether I tell it that a 
>field is a foreign key?  Is that information discarded entirely?  (Which 
>would explain why "describe" doesn't show it.)
>
>The only reason I wanted to know whether a given field was a foreign key, 
>was because I'm hammering together my own Web-based interface to MySQL 
>tables, and I was hoping that when the table contents are rendered in an 
>HTML table and a given field is a foreign key, I can have its value 
>hyperlinked to the appropriate row in the table that it references.
>
>         -Bennett
>
>[EMAIL PROTECTED]     http://www.peacefire.org
>(425) 649 9024
>
>
>---------------------------------------------------------------------
>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
>


[EMAIL PROTECTED]     http://www.peacefire.org
(425) 649 9024


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