[Phpmyadmin-devel] On relation table field names
Marc Delisle
Delislma at CollegeSherbrooke.qc.ca
Wed Jun 26 08:46:01 CEST 2002
Jay Davis wrote:
> Hello:
>
> Despite field name changes for the relation table fields in 2.3.0, the
> relation table field names still seem to be misnamed.
If we take the example "an invoice has many items", it would be clearer
to say that the invoice is the *master* table, and items is the *detail*
table. A simplified example:
CREATE TABLE invoice (
invoice_id tinyint(4) NOT NULL auto_increment,
invoice_date date,
PRIMARY KEY (invoice_id))
CREATE TABLE items (
invoice_id tinyint(4),
item_number tinyint(4),
description varchar(100),
PRIMARY KEY (invoice_id, item_number))
---------------------------------------------
If we take the example in Documentation.html:
CREATE TABLE persons (
id tinyint(4) NOT NULL auto_increment,
person_name varchar(32) NOT NULL default '',
town_code varchar(5) default '0',
country_code char(1) NOT NULL default '',
PRIMARY KEY (id)
) TYPE=MyISAM;
CREATE TABLE towns (
town_code varchar(5) NOT NULL default '0',
description varchar(30) NOT NULL default '',
PRIMARY KEY (town_code)
) TYPE=MyISAM;
CREATE TABLE countries (
country_code char(1) NOT NULL default '',
description varchar(10) NOT NULL default '',
PRIMARY KEY (country_code)
) TYPE=MyISAM;
We can think of the table persons as the master table, because we put
the emphasis on the person. Then, the town_code in persons is a foreign
key linking to table towns, where town_code is the primary key. But in this
case, can we talk about master/detail relationship?
So it's not easy to have only one way to describe various cases, but I think that
the field names in our relation table are clear enough.
--
Marc Delisle
More information about the Developers
mailing list