Continued from page 1
Step Three: Defining Fields
Once you have created your table you will be prompted to tell database what features that you want each field to have. This looks complicated, but its not if you select your data type from information below. You basically have to decide between three common data types and select best choice for storing your data. If you make a mistake you can go back and edit field.
If field is to be used to store numbers, here are some choices:
TINYINT A very small integer. The signed range is -128 to 127. SMALLINT - A small integer. The signed range is -32768 to 32767. MEDIUMINT - A medium-size integer. The signed range is -8388608 to 8388607. INT - A normal-size integer. The signed range is -2147483648 to 2147483647. BIGINT A very large integer.
Some other less common number options include:
FLOAT- A floating-point number. DOUBLE A double-precision floating-point number. DECIMAL - A packed exact fixed-point number.
If field is to be used to store text or both text and numbers combined, here are some choices:
VARCHAR is for varying characters and can be up to 255 characters in length. TEXT is a column with a maximum length of 65,535 characters easy to search. BLOB is a column with a maximum length of 65,535 characters case-sensitive.
If field is to be used to store dates, here are some choices:
DATE - A date. DATETIME - date and time combination. TIMESTAMP - useful for recording date and time of an INSERT or UPDATE operation. TIME - A time.
Once you have selected data type for your fileds you will need to let system know how many characters that you will need to store in field.
Example: if you are storing a username, you might want to select VARCHAR as your data type and allow up to 100 characters for that field. If you are creating a User Identification number you might want to select INT and allow up to six characters that would allow you to have up to 999,999 users.
The last step to creating your data fields is to select any special attributes that you may find helpful. Some examples are:
Auto Increment : Auto-Increment fields are useful for assigning unique identification numbers for users, products, and customers, etc. By default, fields are incremented using number characters (like "1", "2").
Primary Key: The primary key is a data column that uniquely identifies a specific instance of that data. At least one of your fields must be a Primary Key. Username is an example of a good primary key. You do not want to have more than one individual having same username.
Index Key: Allows you to speed up searches by designating a field as a preferred data source, especially when combining data from multiple tables.
Congratulations, once you have completed these steps you are ready to import data into your new database.
Don Beavers lives in Bryan, Texas and is an enterprise level PHP-MySQL programmer at Datavor Web Directory and at the Shopping Elf Directory .