Dave,

> How does one decide whether to define a table with varchar() or char()
> field definitions?

Use CHAR, if you don't have to care about disk space, and if speed is your
first goal. Using CHARs with lots of spaces in the data can be
counterproductive, though, because MySQL will have to return big result
sets.

> In this case, I'll have names, phones, email, res and mailing addresses
> fields (all of which are relatively short and could be fixed-length) as
> well as a larger TEXT field for general notes.

One thing you might want to do is store the fixed-length fields in one
table, and the variable-length fields in another table, with an ID as
reference between them. TEXT will always be of variable length.

> As a side note, I'd be interested in a high-level reading of how data is
> stored in MySQL databases and how compacting and optimization is done...
> It would have to be an "executive summary" overview so that it didn't my
> eyes bleed, though :-)

Why don't you start here:
http://www.mysql.com/documentation/mysql/bychapter/index.html#Column_types
;-)

Regards,
--
  Stefan Hinz <[EMAIL PROTECTED]>
  CEO / Geschäftsleitung iConnect GmbH <http://iConnect.de>
  Heesestr. 6, 12169 Berlin (Germany)
  Telefon: +49 30 7970948-0  Fax: +49 30 7970948-3


----- Original Message -----
From: "David T-G" <[EMAIL PROTECTED]>
To: "mysql users" <[EMAIL PROTECTED]>
Sent: Sunday, December 15, 2002 9:40 PM
Subject: to var or not to var (char, that is)


> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi, all --
>
> How does one decide whether to define a table with varchar() or char()
> field definitions?  I'm going to be storing things like first and last
> names and mailing addresses, and I originally started planning for
> varchar() so that the extra space wouldn't get allocated but then started
> wondering about variable-length records versus fixed-length records and
> speed issues.  They must both have their used (or else there wouldn't be
> two definitions), and so there must be strong points for each; what are
> they?
>
> In this case, I'll have names, phones, email, res and mailing addresses
> fields (all of which are relatively short and could be fixed-length) as
> well as a larger TEXT field for general notes.  Given the variable nature
> of the TEXT field, maybe varchar is fine even if it might not in other
> cases.  Then, again, I don't know if a TEXT field gets the whole space
> assigned to it even if empty, just like I don't know how [var]chars are
> done...
>
> As a side note, I'd be interested in a high-level reading of how data is
> stored in MySQL databases and how compacting and optimization is done...
> It would have to be an "executive summary" overview so that it didn't my
> eyes bleed, though :-)



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to