AUTHOR'S MAIN SITE  > > > > >  TABLE OF CONTENTS for Open Office database tutorials. Delicious.Com Bookmark this on Delicious     StumbleUpon.Com Recommend toStumbleUpon

Open Office Base (database) Tutorials
Field Type (also known as Data Type)

You may find that the database included in OpenOffice delights you as much as it has me. This page tries to help you use it.

Remember that Open Office, including ooBase, is free. Don't let that fool you, though. Big organizations, governmental and civilian, have adopted it as their standard office suite... and saving million$, but still Getting The Job Done. And making things easy for users on different platforms... Linux, Mac, Windows all spoken here!

There's more about ooBase in the main index to this material. Adabas? Star Office? Ancient history.

This page is "browser friendly". Make your browser window as wide as you want it. The text will flow nicely for you. It is easier to read in a narrow window. With most browsers, pressing plus, minus or zero while the control key (ctrl) is held down will change the texts size. (Enlarge, reduce, restore to default, respectively.) (This is fully explained, and there are more tips, at my Power Browsing page.)

Page contents © TK Boyd, Sheepdog Software, 3/06- 10/12.



Field Types, or Data Types

Consider a database to keep track of people in an organization. A nice simple database, with just one table.

We'll set up the following fields...

Many of the above, and many of the choices below are oversimplified to avoid unnecessary complications. Unnecessary to our purpose of exploring "what is a 'data type'?" Don't worry about "Well, that wouldn't be any good..." type questions... here... please?

ID: For the purposes of our discussion, each person within the organization will have an ID which will be just a number. The number will "belong" to one person for evermore; it will not be "re-cycled" if, say, person "0251" leaves, and a new person comes along afterwards. (The new person will not be given the "now free" 0251.) (Of course, turning people into numbers is obnoxious, and I wouldn't do it in the real world, but just for this example, we'll do it.)

In database work, in every table, there must be a field where for every record(ShrtDef) what is in that field does not arise in any other record. The table must have a "primary key", and the field used for this must be thus.

(There are ways to produce a primary key from a combination of fields... but that's for later! (With a primary key made by "compounding" (combining the values in two fields) you could have a non-unique value in one, as long as the result of the combination is unique among all the combinations present in the table.))

Name: For our discussion we're going to put the whole name in one field, e.g. "Smith, Joseph".

YrJoined: This will just be something like "2009"

StillWith: Still with organization: Here we will have "y" or "n"

Setting up the database

Whether you set up the table using the "Create In Design View" (my recommendation) or with the "Wizard", you are going to have to generate a list of the fields for each record, give them names, and say what the "Field Type" will be. Depending on the field type, there will be other specifications to decide.

"Field Type" is more generally called "Data Type", in my experience of things computery. Try both if you go to Google.

Why the hassle?

You are asked to state the field type for each field because if the database "knows" the field type, it can optimize both the storage required and the processing. It can also help you avoid bad entries in your table.

A very simple database program, much cruder than Open Office's Base, might offer just two field types: "number" and "text". Even that would be a start. If the database knew that a field was of the "number" type, it could reject "Fishcakes" as unacceptable, if you tried to put that value in the field.

Open Office Field Types

The broad categories of data types available to you are:

That's one way of grouping the types... and probably the most important way to do it.

You could also split all of the types into these two categories:

This discussion will not be exhaustive... there are types which I won't explain here.

The two most important types for strings of characters are Text(fix)[CHAR] and Text[VARCHAR]. In each case, you will specify the maximum number of characters to be allowed for values stored in the field.

We would use one or the other for our "Name" field.

I believe that the difference between the two is that if you use the first, and specify that the longest allowed string is 28 characters long, then on the disk, each record will have 28 bytes of space set aside for this field. You will be able to enter shorter strings. In the case of the latter, if the first record has "Smith, Joe" in it, and the second has "Metcalf-Gibson, Alexander", then if you've used Text[VARCHAR], only ten bytes of your disk's space will be used for Joe, but 25 will be used for Alex. Has to be good, yes? Well... yes and no. Good for disk space efficiency, but the database may be able to process the information more quickly if every field's datum is of the same length. Hence various data types, so you can choose something to meet your needs!

We'd use Text(fix)[CHAR] for the "Still With Organization" field, and set the length to 1. There are also ways to say to the database "only accept a "y" or an "n" in this field".... but that's not part of the data's type

The "text" data types give you great flexibility.

If the field "only" needs to hold a number, though, use an appropriate type. You may or may not want to avail yourself of the special types for dates and times. Another approach to them is separate simple numeric fields for "year", "hour", etc.

Moving on, looking at "simple" (my term) numeric types, the first big divide is "integers"/"non-integers"... in other words, "whole numbers", or numbers with fractions. If you can do your job with integers, use them. (Less complicated for computer... so faster, and some odd problems avoided.) I sometimes record cash figures inside the computer in pennies, so as to avoid having to use fractions. It also speeds data entry, once you are used to "seeing" $21.98 as 2198.

Computers, as you know, work (mostly) in binary; we work in decimal. Hence some things that seem strange.

Once we've decided we're only interested in integers, the next decision is "signed or not signed?" In other words: Do you need negative numbers?

According to http://wiki.openoffice.org/wiki/Base/Data_Types, if you don't need negative numbers, and you only need 0-255 (which makes sense, if you go into the binary/decimal issues), then you can use the TinyInt [TINYINT] type, and store the data using only one byte of disk space per datum. The table designer dialog says you will use three bytes. Sigh. There are five data types you can use for storing integers. BigInt[BIGINT] lets you store integers from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807... but it takes 8 or 19 bytes, depending on who you ask.

Further help with field types

That's not "everything" about data types... but enough to give you what you need, I hope? If not, I offer a more extensive discourse on field types (data types) as used in Open Office.




Editorial Philosophy

I dislike 'fancy' websites more concerned with a flashy appearance than for good content. For a pretty picture, I can go to an art gallery. Not everyone has fast broadband.

I present this material in a format aimed at to helping you USE it. There are two aspects to that: The way it is split up, and the way it is posted. Details at my page about how the material is split up and how it is posted.

Please remember the material is copyright. (TK Boyd, 2006 and later) The procedures in the page just cited are suggested only for convenient personal use of the material, however, also....

Feel free to use this information in computer courses, etc, but a credit of the source, quoting the URL, would be appreciated. If you simply copy the pages to other web pages you will do your readers a disservice: Your copies won't stay current. Far better to link to the original pages, and then your readers will see up-to-date versions. For those who care- thank you. I have posted a page with more information on what copyright waivers I extend, and suggestions for those who wish to put this material on CDs, etc. (There is at least one prison using the material for inmate education. Situations do exist where good internet connections are not possible!)

Translations are welcomed. Tell me about yours, so I can post links to it. (More information at the page about copyright waivers.)


Ad from page's editor: Yes.. I do enjoy compiling these things for you... I hope they are helpful. However.. this doesn't pay my bills!!! If you find this stuff useful, (and you run an MS-DOS or Windows PC) please visit my freeware and shareware page, download something, and circulate it for me? Links on your page to this page would also be appreciated!

PLEASE >>> Click here to visit editor's Sheepdog Software (tm) freeware, shareware pages <<< PLEASE


If you liked this ooBase tutorial, see the main index for information other help from the same author.

Editor's email address. Suggestions welcomed!     - - -    Want a site hosted, or email? I like 1&1's services.




Valid HTML 4.01 Transitional Page tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org


One last bit of advice: Be sure you know all you need to about spyware.

. . . . . P a g e . . . E n d s . . . . .