1. Technology

Zarko Gajic your About Delphi Guide About Delphi Programming
From Zarko Gajic, your Guide to Delphi Programming
http://delphi.about.com

A Beginner’s Guide to Delphi Programming - Chapter 16
Delphi Personal edition does not offer database support. In this chapter, you will find out how to create your own *flat* database and store any kind of data - all without a single data aware component.
http://delphi.about.com/library/weekly/aa0805503a.htm

Welcome to the sixteenth chapter of the FREE online programming course:
A Beginner’s Guide to Delphi Programming.
Delphi Personal edition does not offer database support. In this chapter, you will find out how to create your own *flat* database and store any kind of data - all without a single data aware component.

No DB support in Delphi Personal edition
As you probably know, Delphi Personal edition comes with no database support, in terms of data-aware components. Hopefully, "data world" isn't only about Paradox, Access, Interbase or MySQL.

The data your application needs to operate on may not always be stored in a relational database. It may be stored in an ASCII text file or a structured binary file. It may even be stored in an XML file.

As you will learn from this chapter, your application can read data from a file (of *any* structure), update "fields", add new "records", and write data back to the file as if the data were stored in a *real* database.

NOTE: flat-file databases are not as scaleable (and safe) as the relational model databases (MySQL, MS SQL Server, Interbase, etc). If you are only working with a small amount of data that is rarely updated then a flat-file database could be your choice.
However, if you are looking for a database for more frequent and heavy use then a relational database is probably more suitable. Be sure to check our "Beginner's Guide to Delphi Database Programming"!

Files from Delphi perspective
Simply put a file is a binary sequence of some type. In Delphi, there a three classes of file: typed, text, and untyped. Typed files are files that contain data of a particular type, such as Double, Integer or previously defined custom Record type. Text files contain readable ASCII characters (organized into lines). Untyped files are used when we want to impose the least possible structure on a file.
Building your own database system
The next series of articles shows you how to use Delphi to create a simple "database" application that interacts with data in text (ASCII) or binary files:
  • Handling ASCII (text) files from Object Pascal code
    Simply put, text files contain readable ASCII characters. Although it is possible to make changes within text file, jump around when processing information or add some data to the file other than at the end, it is advisable to use a text file only when we know that we are working with ordinary text and no such operations are necessary.

  • Your own database
    Working with binary files from Delphi. Use Delphi to manage writing, reading and updating your own types of files. Writing and reading. Seeking and positioning. Changing and updating.

  • Files with no structure (untyped files)
    Using Delphi to manage operations on untyped files - direct access to disk files regardless of type and structuring.

  • Various File IO articles and tutorials
    Including: Understanding what files are and choosing a Delphi file type. What is a File? How are they stored? What format is best for my project (text, files of record or untyped)?

  • Accessing 'Configuration Settings' files (.INI) with Delphi
    How a simple text file can beat Registry in storing a few pieces of application specific configuration data.

  • File Management Routines
    A list of Delphi's RTL functions designed to ease file management.
Some exercises for you...
This time an easy one: download the example Delphi project for this chapter and try out the code without having to type it in yourself. The source units also expand some concepts beyond the scope of this chapter and provide more technical explanations.

   To the next chapter: A Beginner's Guide to Delphi Programming
This is the end of the fifteenth chapter, in the next chapter, we'll deal with windows messages and how to use them to your advantage.

If you need any kind of help at this point, please post to the Delphi Programming Forum where all the questions are answered and beginners are treated as experts.

{
Zarko Gajic, BSCS
About.com Guide to Delphi Programming
http://delphi.about.com
email: delphi@aboutguide.com
free newsletter: http://delphi.about.com/library/blnewsletter.htm
forum: http://forums.about.com/ab-delphi/start/
}

©2014 About.com. All rights reserved.