automatic joint in QBE example

This commit is contained in:
Marc Delisle
2002-04-26 13:55:23 +00:00
parent 5e6b69d350
commit 5a76d663a0
2 changed files with 67 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ $Source$
* tbl_qbe.php3: automatic joints from Relation table, thanks * tbl_qbe.php3: automatic joints from Relation table, thanks
to Mike Beck (mike.beck at ibmiller.de) to Mike Beck (mike.beck at ibmiller.de)
(experimental: some things remain to be tested) (experimental: some things remain to be tested)
* Documentation.html: example for automatic joints
2002-04-26 Alexander M. Turek <rabus@users.sourceforge.net> 2002-04-26 Alexander M. Turek <rabus@users.sourceforge.net>
* libraries/common.lib.php3: fixed a controluser bug. * libraries/common.lib.php3: fixed a controluser bug.

View File

@@ -593,6 +593,10 @@ $cfg['PmaAbsoluteUri'] = (!empty($HTTPS) ? 'https' : 'http') . '://'
display links on the table properties page, to check referential display links on the table properties page, to check referential
integrity (display missing foreign keys) for each described key. integrity (display missing foreign keys) for each described key.
</li> </li>
<li>
in query-by-example, create automatic joints (see an example
in the FAQ, section &quot;Using phpMyAdmin&quot;).
</li>
</ul> </ul>
<br /> <br />
@@ -1533,6 +1537,68 @@ $cfg['PmaAbsoluteUri'] = (!empty($HTTPS) ? 'https' : 'http') . '://'
this document. this document.
</p> </p>
<p>
<b>How can I use the relation table in Query-by-example?</b>
<br />
Here is an example with the tables persons, towns and countries. Start
by creating this: <br /><br />
<tt>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CREATE TABLE countries (<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;country_code char(1) NOT NULL default '',<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;description varchar(10) NOT NULL default '',<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PRIMARY KEY (country_code)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;) TYPE=MyISAM;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;INSERT INTO countries VALUES ('C', 'Canada');<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CREATE TABLE persons (<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;id tinyint(4) NOT NULL auto_increment,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;person_name varchar(32) NOT NULL default '',<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;town_code varchar(5) default '0',<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;country_code char(1) NOT NULL default '',<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PRIMARY KEY (id)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;) TYPE=MyISAM;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;INSERT INTO persons VALUES (11, 'Marc', 'S', '');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;INSERT INTO persons VALUES (15, 'Paul', 'S', 'C');<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CREATE TABLE relation (<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;src_table varchar(32) NOT NULL default '',<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;src_column varchar(32) NOT NULL default '',<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dest_table varchar(32) NOT NULL default '',<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dest_column varchar(32) NOT NULL default '',<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PRIMARY KEY (src_table,src_column)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;) TYPE=MyISAM;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;INSERT INTO relation VALUES ('persons', 'town_code', 'towns', 'town_code');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;INSERT INTO relation VALUES ('persons', 'country_code', 'countries', 'country_code');<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CREATE TABLE towns (<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;town_code varchar(5) NOT NULL default '0',<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;description varchar(30) NOT NULL default '',<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PRIMARY KEY (town_code)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;) TYPE=MyISAM;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;INSERT INTO towns VALUES ('S', 'Sherbrooke');<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;INSERT INTO towns VALUES ('M', 'Montr<74>al');<br />
</tt>
<br />
Then test like this:
<ul>
<li>Click on your db name in the left frame</li>
<li>Choose &quot;Query by example&quot;</li>
<li>Use tables: persons, towns, countries</li>
<li>Click &quot;Update query&quot;</li>
<li>In the fields row, choose persons.person_name and click the
&quot;Show&quot; tickbox </li>
<li>Do the same for towns.description and countries.descriptions in
the other 2 columns</li>
<li>Click &quot;Update query&quot; and you will see in the query box
that the correct joints have been generated</li>
<li>Click &quot;Submit query&quot;</li>
</ul>
</p>
<a name="faqproject"></a> <a name="faqproject"></a>
<h3>[phpMyAdmin project]</h3> <h3>[phpMyAdmin project]</h3>
<p> <p>