ParadoxQuery
============
a product by Abacadabra Software

In this document you'll find the following chapters:

--  What is ParadoxQuery?

--  Some SQL examples.

--  How the job is done.

--  Delphi version compatibility.

--  Properties and methods.

--  Installation.

--  Ordering information.

--  Contact information.

=================================================================================
What is ParadoxQuery?
=================================================================================

ParadoxQuery is a Delphi component that enables you to use standard SQL
to create paradox tables. You can also call it extended local SQL. 

ParadoxQuery enables you to declare foreign key constraints, null constraints,
unique constraints, defaultvalues and check constraints the same way you would
do for SQL databases. Both column and table constraints are supported. 
Declaration of foreign keys will result in Referential Integrity checks, 
declaration of a not null constraint will result in a required field, declaration
of unique constraints can result in a unique index and declaration of a check 
constraint will result in one or more validity checks.

The component is a descendent of the well-known TQuery. You can use it as a
normal TQuery. Simply call "execsql" to execute the query. ParadoxQuery will
parse the statement and will create the table for you. An extra feature of 
paradoxquery is the availability of the table-information (number of foreign
keys, primary keys etc.) which can be accessed after the statement successfully
has been parsed. 


=================================================================================
Some SQL examples.
=================================================================================

The following examples will result in paradox tables including validity checks,
referential integrity and eventually unique-indexes.

CREATE TABLE Team_product(
FK_Team_number VARCHAR(10) NOT NULL,
FK_Prod_id INTEGER NOT NULL,
FOREIGN KEY (FK_Team_number) REFERENCES team (Team_number),
FOREIGN KEY (FK_Prod_id) REFERENCES product (Prod_id),
PRIMARY KEY (FK_Team_number,FK_Prod_id));

CREATE TABLE JOB(
Job_grade SMALLINT NOT NULL,
Job_code VARCHAR(5) NOT NULL,
Job_country VARCHAR(20) NOT NULL,
Job_requirement VARCHAR(80) NOT NULL,
Job_title VARCHAR(20),
Min_salary NUMERIC (8,2),
Max_salary NUMERIC(8,2) DEFAULT 2000,
PRIMARY KEY (Job_grade,Job_code,Job_country),
Check (Min_salary>5 and Min_salary<3000)
);

CREATE TABLE Maintenance_team(
Team_number VARCHAR(10) NOT NULL PRIMARY KEY,
Team_name VARCHAR(20) NOT NULL,
Team_leader VARCHAR(50) NOT NULL DEFAULT "Nobody",
Location VARCHAR(30),
Money_For_Team MONEY DEFAULT 0 CHECK (Money_For_Team>10),
UNIQUE(Team_name, Team_Leader))


=================================================================================
How the job is done.
=================================================================================

In the overridden method "execsql" we check if we're dealing with a DDL statement.
If we're dealing with a DDL statement, we're gonna parse this statement. The SQL 
syntax has been defined in the parse-procedure. Before the real parsing starts,
 we filter out the tablename. Now search for the correct separator (a comma). If 
the resulting token isn't a column or a tableconstraint, we add the next token to
the previous token and try it again. When this (composed) token is a valid token,
we can "order" the results of the parse-process. Out of the results of the parse-
process, we can determine if the token is a column-definition, or a table
constraint. We add the data to the corresponding lists (columns with all their
properties, unique constraints, check constraints etc.). After the parsing was
successful we build a local SQL statement which initially will create the table.
After the table initially has been created we use our collected column and
constraints data to complete the table using BDE functions, which enables us to
add validity checks,  referential integrity etc. All this is done in code and you
won't feel anything of it.


=================================================================================
Delphi version compatibility.
=================================================================================

The component is available for Delphi 3-5.


=================================================================================
Properties and methods.
=================================================================================

ParadoxQuery is a descendent of the well-known TQuery and inherits all its pro-
perties and methods. The properties and methods listed below can't be found in
the regular TQuery:

--- Public

* procedure GetForeignKeysByReferenceTable(sReferenceTable: string; Value: TStrings);
Fills a stringlist (Value) with all names of column referencing to the table named
"sReferenceTable". Available after parsing.

* procedure GetForeignKeys(Value: TStrings);
Fills a stringlist (Value) with all names of foreign key columns. Available after 
parsing.

* procedure GetReferenceTables(Value: TStringList);
Fills a stringlist (Value) with all names of referenced tables. Available after
parsing.

* procedure GetPrimaryKeys(Value: TStrings);
Fills a stringlist (Value) with names of columns which describe the primary key.
Available after parsing.

* function ColumnByName(sColumnName: string): TAPSColumn;
Returns a the column-object of the column named "sColumnName".

* property Columns[Index: Integer]: TAPSColumn read GetColumn;
Returns a the column-object of the column on index.

* property PrimaryKeyCount: Integer read GetPrimaryKeyCount;
Returns the number of columns in primary keys.

* property ForeignKeyCount: Integer read GetForeignKeyCount;
Returns the number of foreign keys.

* property TableName: string read FsTableName;
Name of table (filtered out of the SQL statement).

* property FullTableName: string read GetFullTableName;
Returns the tablename with ".DB" behind it. (Read only)

--- Published

* property TableLevel: Integer read FnTableLevel write SetTableLevel;
Enables you to specify the paradox table level. Default zero which means that ParadoxQuery
will take the default level specified in BDE-admin.

* property BeforeParsing: TNotifyEvent read FBeforeParsing write FBeforeParsing;
Event which fires before the parsing of the statement starts.

* property AfterParsing: TNotifyEvent read FAfterParsing write FAfterParsing;
Event which fires after the statement succesfully has been parsed,

* property UseUniqueIndexes: Boolean read FbUseUniqueIndexes write FbUseUniqueIndexes;
If true, unique constraints will lead to unique indexes. If false, unique constraints will
be ignored.


=================================================================================
Installation.
=================================================================================

Each Delphi-version has got it own directory (d2/d3/d4/d5).
The zipfile contains a demo-application (executable) that shows you the
capabilities of ParadoxQuery. This demo can be started without any installation.

To install the component in Delphi 3-5:

Select in the menu "file" item "open".
Browse to the subdirectory d3,d4 or d5 (depending on your delphi-version).
Select delphi package (*.dpk) AbaD3, AbaD4 or AbaD5.
In the "package"-window press compile followed by "install".
The component will be installed and can be found in tab "abacadabra". 
Close the Delphi-package.
Please include path to component in your search-path (project-options) if Delphi
can't find the DCU. (don't forget the sub-directory per Delphi-version (d3/d4/d5)).

* Note that the evaluation-version only includes the DCU's (delphi compiled units).
** Note that the evaluation-version has got a limitation in the number of columns
   (7) of a paradox table.


=================================================================================
Ordering information.
=================================================================================

Registered users will get:
- The source-code of paradoxquery (paradoxquery.pas)
- Full support
- Free upgrades
- A version that is not limited in the number of columns for the paradox-table.

Before ordering any of our products you must read the software license. This
license can be found in the same directory as this file and is called
"license.doc".

For actual prices and for ordering information you can go to our web-page:
http://home.wanadoo.nl/abacadabra/index.html


Prices (as for November 18, 1999-Feb 1, 2000) per developer in USD.

** ParadoxQuery inclusive source-code (paradoxquery.pas)             $52.50 
** ParadoxQuery without source-code (No limitations in the 
   number of columns)                                                $30.00 
** Extra developer license (Allows product usage by one extra
   developer)                                                        $10.00

How to order?

Online orders can be placed on our web-site. This is far most the easiest and
fastest way to obtain our products. For online orders we can accept all kind of
credit cards, cash,... The address: http://home.wanadoo.nl/abacadabra/index.html

Another way to order our products is by filling out the orderform (orderform.txt)
and send it along with a check made payable to Abacadabra Software to the address
found at the end of this document. In case you choose to do it this way, please
let us know (by sending an email to the emailaddress found at the end of this
document) that you've send a check or orderform. (You may also attach the 
orderform in that email).


=================================================================================
Contact information.
=================================================================================

We've got one email-address for all your questions (sales/support/information):
abacadabra@wanadoo.nl

On our website you can download the latest versions and you can order our
products:
http://home.wanadoo.nl/abacadabra/index.html

Address (for checks/orderforms etc):
Abacadabra Software
Van Faukenbergestraat 8
2274 RZ  Voorburg
The Netherlands
070-3853488

