Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Composite Key Problem?

Composite Key Problem?

From: Joe Condle <condle_at_med.pitt.edu>
Date: Tue, 05 May 1998 13:02:53 -0400
Message-ID: <354F463D.45CA@med.pitt.edu>


I am trying to design queries to help determine different levels of matching records. I have a table of the following form

TABLE 1

 ID             NOT NULL VARCHAR2(32)
 LNAME          NOT NULL VARCHAR2(32)
 FNAME          NOT NULL VARCHAR2(32)
 MNAME          NOT NULL VARCHAR2(32)
 DOB            NOT NULL DATE
 SEX            NOT NULL VARCHAR2(32)
 RACE           NOT NULL VARCHAR2(32)
 ADDRESS        NOT NULL VARCHAR2(128)
 PHONE          NOT NULL VARCHAR2(32)
 ACCT           NOT NULL VARCHAR2(32)
 SSN            NOT NULL VARCHAR2(32)

This table has about 500,000 entires

   I have created a new table based on the first with this form

TABLE 2  

 IDA            NOT NULL VARCHAR2(32)
 IDB            NOT NULL VARCHAR2(32)
 LNAME          NOT NULL VARCHAR2(32)
 FNAME          NOT NULL VARCHAR2(32)
 MNAME          NOT NULL VARCHAR2(32)
 DOB            NOT NULL DATE
 SEX            NOT NULL VARCHAR2(32)
 RACE           NOT NULL VARCHAR2(32)
 ADDRESS        NOT NULL VARCHAR2(128)
 PHONE          NOT NULL VARCHAR2(32)
 ACCT           NOT NULL VARCHAR2(32)
 SSN            NOT NULL VARCHAR2(32)
 

Table 2 has a composite key of (IDA, LNAME, FNAME, DOB, SEX)  

I then run my plsql program that marches down a cursor made up of table1 and does a select against another cursor made up of table1 in an inner loop. The second cursor select statement looks like this: select * from table1

where a.lname = b.lname  
and   a.fname = b.fname
and     a.dob = b.dob 
and     a.sex = b.sex
and    a.mrn != b.mrn
 

Without the primary constraint on the table I get 25,964 of records. With the primary key constraint I get 72. This can not be right. Can anyone shed some light on this.

Thanks

Joe Condle
System Engineer
Medical ARchival Systems Inc.
University of Pittsburgh Medical Center Received on Tue May 05 1998 - 12:02:53 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US