Introduction to PowerBuilder

HomePrevious Lesson: Creating units Table
Next Lesson: Extended Attributes

Column Attributes

Each column in a table has a range of attributes, such as column name, datatype, width, decimals, etc. To view/change the schema of the units table, invoke popup menu on the table heading and select Alter Table popup menu option. To specify extended attributes, double click on the column/table name to which you want to specify. The value that you can supply to each attribute depends on the database to which PowerBuilder is currently connected. Remember that the tables/indexes/etc� you create here are specific to the connected database and would be stored in that.

Name

This is the name that you use to refer to a column and it can contain any alphanumeric characters, spaces and the underscore character. As explained earlier, the rules vary depending on the connected database. You need not worry about using invalid characters, PowerBuilder gives you an error message if you do it.

It is a good idea to use some form of naming convention for column names. It helps you to identify them quickly in the script. In our example application, we've used the underscore character to separate words in the column names. In some databases, table and column names are case sensitive. I don't know why PowerBuilder doesn't allow you to type names in upper case.

Datatypes

This attribute defines the type of data that will be stored in the column. For a database based upon the Adaptive Server Anywhere engine, there are 14+ possible data types.

These include most of the common types such as char, numeric, date and time. For explanation to the more obscure data types, you should either check PowerBuilder on-line help for the Adaptive Server Anywhere engine or the appropriate manuals from other sources. The list of possible data types will change depending on the type of database you are connected to and the version of the database.

Width

This defines the width, or the maximum number of characters a column can contain. It is a good idea to limit the width of each column, so as to limit the amount of memory assigned to data storage. This use of memory can be wasteful if large amounts are allocated to store small amounts of data.

For example, if you know that the surname of all your contacts would never exceed 30 characters then limit the column to this size. Again, all surnames may not be exactly thirty characters, so it is a good idea to select varchar instead of char datatype. The difference being that a Char datatype always takes the amount of space allocated to it irrespective of the data inside it. On the other hand, varchar takes only the space that is needed to store the actual data.

If the column is of numeric datatype, there is a supplemental attribute called Dec that defines the number of decimal places that should be allowed.

Null Option

This is a Yes/No option, which is used to determine whether or not a column should accept a NULL value. A NULL is an empty undefined value that shouldn't be confused with a zero-length string. The meaning of NULL is "unknown value".

Both NULLs and zero-length strings are used to indicate that an entry has not been made. The distinction between the two entries is based on the reason for omission. A NULL entry indicates that the information is unknown, while using a zero-length string shows that the information is not available. For example, you would use a NULL in a Phone field if you don't know whether your contact has a phone, but use a zero-length string if your contact definitely doesn't have one.

Values must be provided for all columns in the "units" table, so all columns are defined as "NOT NULL".
HomePrevious Lesson: Creating units Table
Next Lesson: Extended Attributes