PHP
  Home arrow PHP arrow Page 4 - Changing Table Structure in phpMyAdmin
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Changing Table Structure in phpMyAdmin
By: Marc Delisle
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 13
    2004-09-28

    Table of Contents:
  • Changing Table Structure in phpMyAdmin
  • Editing Field Attributes
  • BLOB (Binary Large Object)
  • ENUM and SET
  • Index Management
  • Multi-Field Indexes and Index Editing
  • Table Optimization: EXPLAIN a Query

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Changing Table Structure in phpMyAdmin - ENUM and SET


    (Page 4 of 7 )

    Both these field types are intended to represent a list of possible values; the difference is that the user can choose only one value from a defined list of values with ENUM, and more than one value with SET. With SET, the multiple values all go into one cell; multiple values do not imply the creation of more than one row of data.

    We add a field named genre and define it as an ENUM. For now, we choose to put short codes in the value list, and one of them (F) as the default value:

    phpMyAdmin

    In the value list, we have to enclose each value within single quotes, unlike in the default value field. In our design, we know that these values stand for Fantasy, Child, and Novel, but for now we want to see the interface's behavior with short codes. In the Insert panel, we now see a radio box interface:

    phpMyAdmin

    If we decide to have more self-describing codes, we can go back to Structure mode and change the definition for the genre field. In the following example, we do not see the complete value list because the field is not large enough, but what we entered was 'Fantasy', 'Child', 'Novel'. We also have to change the default value to one of the possible values, to avoid getting an error message while trying to saving this file structure modification.

    phpMyAdmin

    With the modified value list, the Insert panel now looks as follows:

    phpMyAdmin

    Observe that the previous radio buttons have changed to a select list because of the longer size of the possible values.

    If we want more than one possible value selected, we have to change the field type to SET. The same value list may be used, but now, using our browser's multiple value selector (usually control-click) we can select more that one value:

    phpMyAdmin


    For the previous example, we would store only the genre codes in the books table in a normalized data structure, and would rely on another table to store the description for each code. In fact, we would not be using a SET or ENUM in this case.

    phpMyAdminThis 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.

    Buy this book now.

    More PHP Articles
    More By Marc Delisle


     

       

    PHP ARTICLES

    - Authentication Scripts for a User Management...
    - Utilizing the Use Keyword for Namespaces in ...
    - Building a User Management Application
    - Working With Different Namespaces in PHP 5
    - User Management Explained: Overview
    - Using Namespaces in PHP 5
    - Database Security: Guarding Against SQL Inje...
    - Building a Modular Exception Class in PHP 5
    - Database and Password Security for Web Appli...
    - Handling MySQL Data Set Failures in PHP 5
    - Building Site Registration for Web Applicati...
    - Intercepting Customized Exceptions in PHP 5
    - Securing Your Web Application Against Attacks
    - Sub Classing Exceptions in PHP 5
    - Authentication for Web Application Security





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
    Stay green...Green IT