Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Character Data-Type Field Width

Status
Not open for further replies.

KDavie

Programmer
Joined
Feb 10, 2004
Messages
441
Location
US
I am in the process of designing a database and am having trouble deciding on the appropriate width for some of my character data-type fields.

If I am not mistaken, VFP will truncate data if the field-width is not sufficient enough to store it. If the field-width is greater than the number of characters needed, then it will still use the same amount of space as it would if it were populated to capacity. Obviously, losing data isn't an option, but I don't want to use a bunch of unnecessary space either.

Does anyone have a method of choosing the appropriate field-width they can share with me? Am I worrying about nothing? Any help would be appreciated.

Thanks,

-Kevin
 
The answer really depends on your situation. If the length of the data varies widely, then you'd be better off using a memo field. If most of the time, the data will be near a set maximum, then a character string would be the best bet.


-BP (Barbara Peisch)
 
To better illustrate my situation, here are some of the fields I am concered with:

cLastName
cAddress
cCity
cBankName

While most last names aren't over, let's say 12 characters, there is bound to be an instance where the last name is more than 12 characters. I'm fairly confident that no name would be more than 20 characters, but if I use that as the field-width then I am basically using twice as much space as I really need to for most of my data. The same applies for the other fields.

Thanks for your help,

-Kevin

 
I wouldn't worry about the extra spaces for fields like this. I usually use 30 character fields for names, addreses, cities, etc.


-BP (Barbara Peisch)
 
Thanks Barbara,

I thought I might be worrying about nothing!

-Kevin
 
Kevin,

This won't help much, but you might like to know that the next release of VFP will support variable-length character fields, in the same way that SQL Server does.

In the meantime, I'd agree with Barbara that this isn't worth worrying about. We all have names, addresses, etc in our tables, and it is not seen as a big issue.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top