Skip to content

Commit 3be760a

Browse files
committed
Rewrite Relations user guide and update screen shots
Signed-off-by: Isaac Bennetch <bennetch@gmail.com>
1 parent cf1d92d commit 3be760a

8 files changed

Lines changed: 30 additions & 11 deletions
-2.22 KB
Binary file not shown.
110 KB
Loading
129 KB
Loading
27.5 KB
Loading
139 KB
Loading
51.7 KB
Loading
66.6 KB
Loading

docs/relations.rst

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Relation view
2828
-------------
2929

3030
In order to get it working, you first have to properly create the
31-
[[pmadb|pmadb]]. Once that is setup, select a table's "Structure" page. Below
31+
:ref:`linked-tables`. Once that is setup, select a table's "Structure" page. Below
3232
the table definition, a link called "Relation view" is shown. If you click that
3333
link, a page will be shown that offers you to create a link to another table
3434
for any (most) fields. Only PRIMARY KEYS are shown there, so if the field you
@@ -39,27 +39,43 @@ record.
3939
Relation view example
4040
+++++++++++++++++++++
4141

42+
Let's say you have a database with employees and their departments. Your table structure would be something like this:
43+
44+
- ``employees.id`` (must be unique)
45+
- ``employees.name``
46+
- ``employees.department``
47+
- ``departments.dept_id``
48+
- ``departments.department_name``
49+
50+
Each employee belongs to only one department, but each department has many employees.
51+
Of course you might also have fields in ``employees`` for things like email address and office number as well as
52+
a third table for current projects or supervisor or any of many other possible details.
53+
4254
.. image:: images/pma-relations-relation-view-link.png
4355

4456
.. image:: images/pma-relations-relation-link.png
4557

46-
Let's say you have categories and links and one category can contain several links. Your table structure would be something like this:
58+
From the ``employees`` table :guilabel:`Structure` tab, open the :guilabel:`Relation view` (just below the menu bar). Select the ``department`` column
59+
as the column to work with and ``departments`` table ``dept_id`` column as that is the referenced key.
60+
We recommend using the native constraints where possible, but there is an :guilabel:`Internal relationships` area for usage when
61+
the table type does not support these natively.
4762

48-
- `category.category_id` (must be unique)
49-
- `category.name`
50-
- `link.link_id`
51-
- `link.category_id`
52-
- `link.uri`.
63+
If you now browse the ``employees`` table, the ``department`` field will be a clickable hyperlink to the proper category record. It will still show the
64+
``dept_id`` instead of the label. A tooltip appears when hovering over the values with the referenced label.
5365

54-
Open the relation view (below the table structure) page for the `link` table and for `category_id` field, you select `category.category_id` as master record.
66+
.. image:: images/pma-relations-links.png
5567

56-
If you now browse the link table, the `category_id` field will be a clickable hyperlink to the proper category record. But all you see is just the `category_id`, not the name of the category.
68+
To further improve this, open the :guilabel:`Relation view` of the ``departments`` table and in the drop down at the bottom, select
69+
``department_name`` (in some cases, this may already be the default setting).
5770

5871
.. image:: images/pma-relations-relation-name.png
5972

60-
To fix this, open the relation view of the `category` table and in the drop down at the bottom, select "name". If you now browse the link table again and hover the mouse over the `category_id` hyperlink, the value from the related category will be shown as tooltip.
73+
Go back to the :guilabel:`Browse view` for the ``employees`` table and expand the :guilabel:`Extra options` then select
74+
:guilabel:`Display column for relationships`. This shows the text from the referenced table instead of the integer value.
6175

62-
.. image:: images/pma-relations-links.png
76+
.. image:: images/pma-relations-display-column.png
77+
78+
This preference can be set in :config:option:`$cfg['RelationalDisplay']` or the user preferences.
6379

6480
Designer
6581
--------
@@ -74,6 +90,9 @@ must have the :config:option:`$cfg['Servers'][$i]['table_coords']` configured.
7490
To use the designer, select a database's structure page, then look for the
7591
:guilabel:`Designer` tab.
7692

93+
.. image:: images/pma-relations-designer.png
94+
95+
You can also export this window, which can be handy to visually reference the database structure.
7796
To export the view into PDF, you have to create PDF pages first. The Designer
7897
creates the layout, how the tables shall be displayed. To finally export the
7998
view, you have to create this with a PDF page and select your layout, which you

0 commit comments

Comments
 (0)