________________

RefInt Component
________________


Brief Description
_________________

Did you ever find the task of managing referential integrities on a Paradox database, table by table, taking care of operation order, somewhat tedious ? So did I. That's why I decided built this component.

Later I added the ability to backup the referential integrity information in a special little paradox database. This can be useful for database maintenance purpose. Make a backup when the database is clean for the case you have to set referential integrities again after data corruption occured.

RefInt allows you to quickly visualize and modify foreign keys from a unique centralized tool, always doing the restructuration of the involved tables in the right order. If you ever do it manually, you should appreciate.

RefInt works with four DBGrids which roles are :

To list dependant tables and allow to select one (top left grid in demo)

To list fields of the current dependant table and allow to select one (top right grid in demo)

To list master tables and allow to eventually select a master table for the current dependant table (bottom left grid in demo)

To list fields of the current master table and allow to select one (bottom right grid in demo)


Setup
_____

For VCL version only :

Unzip the RefInt.zip file you received, this will give you 14 files and 2 directories containing the RefInt.dcu, Unit1.dfm, and Unit1.dfm files that are version dependent. Move the content of the directory corresponding to your Delphi version into the same directory as RefIntReg.pas, then use Component/Install component in your Delphi IDE main menu to add RefIntReg.pas to a package. Compile the package. This will install the RefInt component.

You may leave the database working files (Table.db, Table.px, Field.db, Field.px, Field.val) and backup files (STable.db, STable.px, SField.db, SField.px, SField.val) in the project directory (more precisely they should be in the exe directory), or you may move them in a separate directory. In the latter case, make an alias pointing to this directory. This alias name has to be set as the InternalAliasName property value of the RefInt component. You also have to do it in the demo project.

For exe version only :

Unzip, then execute Refint.exe.


Reading referential integrities
_______________________________

1) Select a dependant table (top left)
2) Select a dependant field of this table (top right)
3) Master table and master field (if any) appear as focused in bottom grids

Adding a referential integrity
_______________________________

1) Select a dependant table (top left)
2) Select a dependant field of this table (top right)
3) Select a master table (bottom left)
4) Select a master field (bottom right)

Removing a referential integrity
________________________________

1) Select a dependant table (top left)
2) Select a dependant field of this table (top right)
3) Master table and master field appear as focused in bottom grids
4) Click on the master field to unselect it (bottom right)


Public properties
_________________

Changed : boolean;

	Indicates if a change occured in the referential integrities.



Public procedures
_________________

procedure ClearAll;

	Clears all referential integrities.

constructor Create(AOwner:TComponent); override;

	Creates an instance of class TRefInt.

procedure ReadFromDatabase;

	Reads all referential integrities from the selected database and display them in the grids

procedure ReadFromFile;

	Reads all referential integrities from the backup database and display them in the grids

procedure WriteToDatabase;

	Writes all defined referential integrities into the selected database.

procedure WriteToFile;

	Writes all defined referential integrities into the backup database.


Published properties
____________________

Active : boolean;

	Indicates if RefInt is active or not.

AliasName : string;

	Alias name of the database you are setting referential integrities.

DBGTables : TDBGrid;

	DBGrid showing Tables of the database (master of DBGFields)

DBGFields : TDBGrid;

	DBGrid showing Fields of tables (detail of DBGTables)

DBGParentTables : TDBGrid;

	DBGrid showing parent tables of the current field in DBGFields

DBGParentFields : TDBGrid;

	DBGrid showing parent field of the current field in DBGFields

InternalAliasName : string;

	Alias of the directory containing the tables Table.db and Fields.db used by RefInt.
	This should be left blank if the working and backup database files are in the same directory as the .exe


Warnings
________

Because order has an importance, RefInt always clears all integrities before setting new ones. If something goes wrong at a given point (you try to make a link between incompatible fields, for example) only those integrities that were already set before this point will be in the database.  
I tried to clear and write integrities in a database transaction that was rollbacked in case of problem, but it reported a lock error on table resttemp.db. It is recommended to make a backup copy of your Paradox database before using RefInt, just in case where things would go wrong.

RefInt can read foreign keys from other BDE-supported databases, but only Paradox is currently supported for integrity writing.

I was unable to locate the primary key of those Oracle tables that have no foreign keys nor are master of another table. If someone knows a solution...


Disclaimer
__________

A great care was given to the design of this component. Nevertheless, the author does not garanty that the component will fit your need, nor that it will be 100 % bug-free. If you use it, do it at your own risks.



Next versions
_____________

If you are interested in receiving by e-mail the next evaluation versions of RefInt, please let me know.


Distribution
____________

RefInt is royalty free. You can distribute it as long as you don't modify the copyright messsage.


Source code
___________

Source code is available for $50. Buyers of source code are not authorized to distribute it nor to distribute part of it without my explicit agrement.




                              					Christophe Dary

								cdary@usa.net 
