In previous versions of 4D, the only way to set a relation was to draw one from the Database Structure view in Design environment. A new command in 2004.1 allows you to set a relation programatically. This command called, AP Create relationship, is brought to you through 4D Pack.
To set a relation you could write a command similar to the following:
This command will set a relation from [Table 1]Field1 to [Table 2]Field1 assuming Table 1 is the first table and Table 2 is the second table. The variable $status will contain an error code if the command failed.