|
Posted by J.O. Aho on 11/19/06 07:27
sTony wrote:
> CREATE TABLE ZipCodes
> -- A list of ZipCodes.
> (
> id int(7) UNSIGNED NOT NULL DEFAULT '0' auto_increment,
> ZipCode string(7) NOT NULL,
> PRIMARY KEY(id)
> );
This table doesn't do much at all, it just hogs up hard drive space.
CREATE TABLE ZipCodes
-- A list of ZipCodes and the area they cover
(
ZipCode string(7) NOT NULL,
AreaName string NOT NULL,
PRIMARY KEY(ZipCode)
);
Use better names for "id", is it's a users id, then use user_id in all tables
where it's the users id number. You can only have AUTO_INCREMENT for the id
only in it's main table, if you use it in another table too, then the column
can't have AUTO_INCREMENT.
When you create a relations table, then use two id's, and make those together
as a primary key, don't create a new id in a relation table, it's just waste
of space.
Don't normalize everything, look more on what you will need often together,
JOINS takes time, specially when you start to have much of data in your tables.
I guess you mean FORUM and not CHAT in your last tables.
I suggest you start all over again, begin with unnormalized tables, look at
what you have in your table what data that can occur more than once and break
it out and you don't always need a "relation table2 as some data like zipcode
you always have a one to one relation. Other times you save a lot of speed to
not normalize like zipecode and areaname, even if many zipcodes can have the
same area name, the name isn't really long, so you won't be waisting that much
space (space vs speed).
//Aho
Navigation:
[Reply to this message]
|