Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    sql
  » MySQL Table Advise
      by Admin
 Page 1 of 1 
   

(Login to remove green text ads)
So your all set up to create your first dynamic website and you plan on using MySQL to store all your sites data, nice choice.

Here are a couple pointers on creating your table.
  • Define your datatypes correctly.
  • Name the table something easy to remember.
  • Name the columns something easy to remember.

1. *Primary Key* A primary key will keep all your rows of data unique. This will make it much easier to maintain your data later on. If you fail to use a primary key data corruption when updating your site is likely.

create table key_example (id int(6) not null auto_increment, more table definitions here, primary key(id));
This table is using 'id' as the primary key. Setting up the primary key as an int and using auto_increment make this a very easy way to use a primarty key.

2. *Datatypes* Defining all datatypes correctly will allow you to use the data with all programming languages. Setting a column to a number type will allow you to run math operations on those values. Failure to do this may cause more work for you later, so just define your fields properly.

3. *Table Name* Naming your table something relevent to what the data is used for will help you out when you have 40+ tables in a single database. I dont know how many times I have had to ask other developers what they named a table for a specific job because they named it something like 'XYZ123'. This will save headaches when you are working on large scale projects

4. *Column Names* See Table Name above.




 
 Page 1 of 1 
   

Rate This Article
1 2 3 4 5 6 7 8 9 10





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle