This chapter explores editing table definitions and using special column types. When developing Web applications (or any application), requirements often change because of new or modified needs. Developers must accommodate these changes through judicious table-structure editing. This is chapter six of Mastering phpMyAdmin for Effective MySQL Management by Marc Delisle (Packt Publishing, April 2004, ISBN 1904811035).
Suppose we need a new field to store a book's language, and by default, the books on which we keep data are written in English. We decide that the field will be calledlanguage, and will be a code composed of two characters (en by default).
In the Structure sub-page of the Table view for the books table, we can find the Add new field dialog. Here, we specify how many new fields we want and where the new fields go.
The positions of the new fields in the table only matter from a developer's point of view; we usually group the fields logically to find them more easily in the list of fields. The exact position of the fields will not play a role in the intended results (output from the queries), because these results can be adjusted regardless of the table structure. Usually, the most important fields (including the keys) are located at the beginning of the table, but this is a matter of personal preference.
In this case, we choose to put the new field At End of Table, which is the first choice in the menu, and click the Go button:
We then see the familiar panel for the new fields, repeated for the number of fields asked for. We fill it, and this time we put a default value, en. We then click on Save.
This panel appeared in horizontal mode, the default for $cfg['DefaultPropDisplay'].
Vertical Mode
If we set $cfg['DefaultPropDisplay'] to 'vertical', the panel to add new fields (along with the panel to edit a field's structure) will be presented in vertical order. The advantages of working in vertical mode become obvious especially when there are more choices for each field, as explained in Chapter 16 on MIME-Based Transformations.
Let's see how the panel appears if we are in vertical mode and ask for three new fields:
This chapter is from Mastering phpMyAdmin for Effective MySQL Management by Marc Delisle (Packt Publishing, April 2004, ISBN 1904811035). Check it out at your favorite bookstore today.