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
    forums
Old 02-24-2003, 02:01 PM   #1 (permalink)
Admin
$_['Your_Mom'];
 
Admin's Avatar
 
Join Date: May 2002
Location: Santee
Posts: 627
Admin is on a distinguished road
MySQL Table Advise

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.
Admin is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Resetting a table from a backup copy... metazai PHP 15 06-23-2004 12:58 PM
Table problems prendo HTML, XML, Javascript, AJAX 12 04-06-2003 05:38 AM
broken mysql table? sde PHP 1 03-31-2003 06:30 PM
help me name a table sde Lounge 4 12-07-2002 12:50 PM


All times are GMT -8. The time now is 03:59 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting