Re: Foreign Keys & Primary Keys
Posted in 1997
Barry Stubbs wrote: > > I know this is a simple question, but I just can't find a simple answer. I > have two entities as follows with only their primary keys listed: > > TEA_REF CLASS_TEA > ------------ ------------------ > TEA_CD UNIT_NUM > CLASS_NUM > TEA_CD > > The relationship is TEA_REF(one) to CLASS_TEA(many) with the foreign key as > TEA_CD in CLASS_TEA. Should I also have a separate index for > CLASS_TEA.TEA_CD for that relationship? Or will it being a part of the > primary key suffice for the relationship? If the primary key for CLASS_TEA is: (TEA_CD,...) then yes the index created to support the primiary key relationship is sufficient for the purposes of supporting joins. If the primary key starts with another column then you will need a separate single column or multi-column index starting with TEA_CD to support joins. Art S. Kagel