Database Reference
In-Depth Information
Our goal here is to create a relation between the
book
table (which contains the
author ID) and the
author
table (which describes each author by an ID). We start on
the Table view for the
book
table, go to
Structure,
and click the
Relation view
link.
Internal relations
As the
book
table is in MyISAM format, we see the following screen (otherwise, the
display would be different, as explained in the
Foreign Key Relations
section later):
This screen allows us to create
Internal relations
(stored in the
pma_relation
table)
because MySQL itself does not have any relational notion for MyISAM tables. The
empty drop-down list next to each column indicates that there are no relations (links)
to any foreign table.
Defining the relation
We can relate each field of the
book
table to a field in another table (or in the
same table, because self-referencing relations are sometimes necessary). The interface
finds both the unique and the non-unique keys in all the tables of the same database,
and presents the keys in drop-down lists. (Creating internal relations to other
databases from the interface is not currently supported.) The appropriate choice for
the
author_id
field is to select the corresponding
author_id
field from the
author
table—also called
defining the foreign key
.
Search WWH ::
Custom Search