Fields

Each attribute that you have identified will become a field in the table. In creating a field in a table, some new aspects of the attribute must bé~; considered. The name, data type, and size of the field are the most critical elements of any field. Turn your attention to the name first. It itl ust be an identifier that fully describes the contents of the field so that it will be clear and easy to work with within your application. In a

Part I --The Relational Database complicated database, it is also a good idea to indicate the parent tafeji? (the main table that the field exists in) in the name of the field.

Prepend any identifier that indicates the name of the table that owns the field to the field name. For example, the field Street is a part of the VENDORS table. Name it Ven Street. When this field appears in the program code for your application, it will be crystal clear as to the source and the contents of the field.

Once the field is named, the data type must be set. The database tool with which the relation will be implemented will determine the set of choices. Delphi supports a wide variety of data types, all of which are shown in Figure 2.17. Choosing the appropriate type may take some consideration of the final use of the data. A primary consideration is the differentiation between an Alphanumeric and a Numeric data type.

PARADOX DATA TYPE

DBASE TABLE TYPE

Alpha

Character

Number

Float

Money

Number

Date

Date

Short

Number

Memo

Memo

Binary

Memo

Formatted Memo

Memo

OLE

OLE

Graphic

Binary

Long

Number

Time

Character

DateTime

Character

Bool

Boo!

Autolnc

Number

Bytes

Memo

BCD

N/A

figure 2. I7 Delphi supported data types figure 2. I7 Delphi supported data types

If the data will not be used in any kind of computation, it should be stored as an alphanumeric field. This allows numbers to be format« in standardized ways such as telephone or social security numbers« also to contain numeric sequences (such as the zip codes of the East' United States) that are not numerically correct. Also, pay attention fields that represent Boolean, or true-false, data. Many users are CQ] fortable with Y/N or A/B type data that is more correctly represents with a Boolean data type. The field should contain the correct data type, leaving permutations such as Yes/No to the user interface.

Through the process of normalization, the VENDORS table has undergone considerable change. At the last normalized level, the table is designed in such a way that a database table can now be constructs through the Database Explorer and used in a program. We will disc« this relation-to-table creation process in more detail when we explo the Database Explorer and create some tables.

Was this article helpful?

0 0

Post a comment