Forum Moderators: coopster

Message Too Old, No Replies

Size of Fields

simple but important

         

fashezee

5:58 pm on Sep 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In the process of designing a database; we are having trouble
determing the character size we should allocate for certain
fields. Such as street name, person's first and last name. It is
extremely important for us to keep the database size to a bare minimum
for this particualr project.

I would like to know how you go about determing the sizes of the fields
in the DB.

Gecko

7:49 am on Sep 22, 2003 (gmt 0)

10+ Year Member



I'd suggest to find a well-established open source project, which database structure contains records similar to you ones (for example, osCommerce). Such projects are revisited by many developers and tested in many different conditions. So, they should contain neither too short nor too long DB fields.

jatar_k

2:57 pm on Sep 22, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



how you go about determing the sizes of the fields

By determining the size of the data to be contained within them. I would think you are specifically referring to columns for storing characters.

Maybe take a look at this page which explains storage sizes for CHAR and VARCHAR column types
MySQL CHAR and VARCHAR Types [mysql.com]

So as long as your data is less than 255 chars but not always the same length then varchar makes more sense. If you have a column that will always have the same length of data (x) then go with CHAR(x) as the type.

If you have only 3 possible values then enum('val1','val2','val3') will be fine. If you have a large chunk of data that needs to stored in a single column then you need to look at BLOB and TEXT.

MySQL Column Types [mysql.com]

All that to say that it isn't much of a choice because the data to be stored tells you the format.