<< previous page   --   table of contents   --   next page >>
| | | | | | | |
  • Return to Table of Contents
  • Table of Contents

    1. General Information
    2. MySQL Installation
    3. Tutorial Introduction
    4. Database Administration
    5. MySQL Optimisation
    6. MySQL Language Reference
    7. MySQL Table Types
    8. MySQL APIs
    9. Extending MySQL

    150 MySQL Technical Reference for Version 4.0.3 Note that  menagerie  is not your password on the command just shown.   If you want to supply your password on the command-line after the  -p  option, you must do so with no intervening space (for example, as -pmypassword, not as -p mypassword). However, putting your password on the command-line is not recommended, because doing so exposes it to snooping by other users logged in on your machine. 3.3.2  Creating a Table Creating the database is the easy part, but at this point it's empty, as  SHOW TABLES  will tell you: mysql> SHOW TABLES; Empty set (0.00 sec) The harder part is deciding what the structure of your database should be: what tables you will need and what columns will be in each of them. You'll want a table that contains a record for each of your pets.  This can be called the pet table, and it should contain, as a bare minimum, each animal's name.  Because the name by itself is not very interesting, the table should contain other information.  For example, if more than one person in your family keeps pets,  you might want to list each animal's owner.  You might also want to record some basic descriptive information such as species and sex. How about age?  That might be of interest, but it's not a good thing to store in a database. Age changes as time passes, which means you'd have to update your records often.  Instead, it's better to store a xed value such as date of birth. Then, whenever you need age, you can calculate it as the di erence between the current date and the birth date.  MySQL provides functions for doing date arithmetic, so this is not dicult.  Storing birth date rather than age has other advantages, too:    You  can  use  the  database  for  tasks  such  as  generating  reminders  for  upcoming  pet birthdays.  (If you think this type of query is somewhat silly, note that it is the same question you might ask in the context of a business database to identify clients to whom you'll soon need to send out birthday greetings,  for that computer-assisted personal touch.)    You can calculate age in relation to dates other than the current date.  For example, if you store death date in the database, you can easily calculate how old a pet was when it died. You can probably think of other types of information that would be useful in the pet table, but the ones identi ed so far are sucient for now:  name, owner, species, sex, birth, and death. Use a CREATE TABLE statement to specify the layout of your table: mysql> CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20), -> species VARCHAR(20), sex CHAR(1), birth DATE, death DATE); VARCHAR  is a good choice for the  name,  owner, and  species  columns because the column values  will  vary  in  length.   The  lengths  of  those  columns  need  not  all  be  the  same,  and need not be 20.  You can pick any length from 1 to 255, whatever seems most reasonable to
     

    Customer Support CentreMySQL Reference Manual

    Web Hosting Services
    UNIX WEB HOSTING
    SUPPORT & FAQ's
    TERMS OF USE
    Domain Services
    DOMAIN REGISTRATION
    MANAGE YOUR ACCOUNT
    SUPPORT & FAQ's
    TERMS OF USE
    SITE MAP
    Home
    Hosting Plans | Domain Registration | About Us | Contact Us | Site Map
    Terms of Use | Privacy Policy | Guarantees
    Merchant Accounts

    SpiritHost - web hosting for spiritual and education sites
    SpiritHit.com - Religious and Spiritual Portal
  • Return to Table of Contents
  • Back to top

  • Web Hosting: Manuals & FAQ's

    1. Unix-Based Web Hosting
    2. Unix Dedicated Servers
    3. Windows Dedicated Servers
    4. CuteFTP User’s Guide
    5. CuteHTML User’s Guide
    6. WS_FTP Pro User's Guide
    7. Miva Order User's Guide
    8. Miva Merchant User's Guide