From 5a76d663a026f73a209d191e1de803d2ba6b0563 Mon Sep 17 00:00:00 2001
From: Marc Delisle
@@ -1533,6 +1537,68 @@ $cfg['PmaAbsoluteUri'] = (!empty($HTTPS) ? 'https' : 'http') . '://'
this document.
+ How can I use the relation table in Query-by-example?
+
+ Here is an example with the tables persons, towns and countries. Start
+ by creating this:
+
+ CREATE TABLE countries (
+ country_code char(1) NOT NULL default '',
+ description varchar(10) NOT NULL default '',
+ PRIMARY KEY (country_code)
+ ) TYPE=MyISAM;
+
+ INSERT INTO countries VALUES ('C', 'Canada');
+
+ 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;
+
+ INSERT INTO persons VALUES (11, 'Marc', 'S', '');
+ INSERT INTO persons VALUES (15, 'Paul', 'S', 'C');
+
+ CREATE TABLE relation (
+ src_table varchar(32) NOT NULL default '',
+ src_column varchar(32) NOT NULL default '',
+ dest_table varchar(32) NOT NULL default '',
+ dest_column varchar(32) NOT NULL default '',
+ PRIMARY KEY (src_table,src_column)
+ ) TYPE=MyISAM;
+
+ INSERT INTO relation VALUES ('persons', 'town_code', 'towns', 'town_code');
+ INSERT INTO relation VALUES ('persons', 'country_code', 'countries', 'country_code');
+
+ CREATE TABLE towns (
+ town_code varchar(5) NOT NULL default '0',
+ description varchar(30) NOT NULL default '',
+ PRIMARY KEY (town_code)
+ ) TYPE=MyISAM;
+
+ INSERT INTO towns VALUES ('S', 'Sherbrooke');
+ INSERT INTO towns VALUES ('M', 'Montréal');
+
+
+ Then test like this:
+