mr@cica.cica.indiana.edu (Michael Regoli) (03/15/90)
][ I'm having a little trouble understanding the format of the "SET RELATION TO" command in dBaseIV. I have two databases that I would like to link together. One is a database of names and addresses (R.DBF), and the other is a database of the same individuals with publications they have written (RPUB.DBF). The databases share two fields in common: RID (I.D. number) and LAST. Structure for database: C:\DB\JAH\REVIEW\R.DBF Number of data records: 15 Date of last update : 03/12/90 Field Field Name Type Width Dec Index 1 RID Numeric 5 N 2 FIRST Character 25 N 3 LAST Character 25 N . . 22 KEY10 Character 20 N ** Total ** 437 Structure for database: C:\DB\JAH\REVIEW\RPUBS.DBF Number of data records: 15 Date of last update : 03/12/90 Field Field Name Type Width Dec Index 1 RID Numeric 5 N 2 LAST Character 25 Y 3 B1 Character 250 N 4 P1 Character 30 N 5 D1 Character 4 N . . 32 JD5 Character 4 N ** Total ** 2871 As you can see, the last database is rather large. That is the main reason why I've kept it separate. What I would like to do is open the two databases so that information can be entered into both via an input screen. Can someone provide a little insight into how to link these two? Of particular help would be to describe more clearly the meaning of the syntax of the SET RELATION TO command (e.g., SET RELATION TO <expN> INTO <alias> [, <expN> INTO <alias>]...) So far, I'm thinking of: ** ** relate.prg: set up a relation ** select 1 use r index on rid to r_rid use r index r_rid order r_rid select 2 use rpubs ** ** does rpubs need indexing on rid here? ** set relation to rid into r ** ** now perform whatever, e.g. ** display all r->rid, rpubs->last, rpubs->b1 ** Basically, all I'm concerned with (at the moment :-)), is opening the two databases so information can be placed into them (especially making certain that an individual's publications are kept with his identification number (RID), name and address). I welcome any e-mail on this. Thanks for any pointers! -- michael regoli mr@cica.indiana.edu regoli@iubacs.bitnet ...rutgers!iuvax!cica!mr
awd@dbase.A-T.COM (Alastair Dallas) (03/17/90)
Your posting looks like you understand the SET RELATION command well enough to make it do what you want. It's not clear, but it seems as if the LAST field is redundant in the RPUBS table. Also, you say that the main reason for separating the two tables is that one is rather large; actually, the main reason for separating them should be their one-to-many relationship (one author may write several publications). Your code looks fine, but using dBASE IV you can be more concise. Specifically, use MODIFY STRUCTURE to specify an index on the field 'RID' in table R. This will create a production MDX file (R.MDX). Then your setup code looks like: SELECT 1 USE "RPUBS" USE "R" IN 2 ORDER RID SET RELATION TO RID INTO R DISPLAY B1, P1, D1, R->First, R->Last Hope it helps. /alastair/
englandr@phoenix.Princeton.EDU (Scott Englander) (03/21/90)
In article <471@dbase.A-T.COM> awd@dbase.A-T.COM (Alastair Dallas) writes: > >you say that the main reason for separating the two tables is that >one is rather large; actually, the main reason for separating them >should be their one-to-many relationship (one author may write >several publications). > Exactly, and it appears that Michael's not taking advantage of this. It looks as if he's trying to put all the publications in flat-file format in the RPUBS table, with one record per author, and up to five of the publications on each record. The problem with this is that the number of publications per author is limited and unnecessarily inaccessible. Michael: You should keep info that's specific to an author in the R table, and info that's specific to a publication in the RPUB table. Have one record per publication, and have the RPUBS table point at R via the "RID" index/relation. I'm sorry if i misinterpreted your posting, but nevertheless hope that other "neophytes" can benefit from this discussion even so. -- - Scott