PDA

View Full Version : SQL - Foreign Composite Key?


SilverVenom
10-29-2008, 09:08 PM
Hey,

Any SQL developers out there know how to create a composite key from two foreign keys without actually having the foreign keys in the table you are making your composite key in? (whew that was a mouth-full)

For example, you have 3 tables.

Table 1: It's Primary Key is "C_ID".
Table 2: It's Primary Key is "P_ID".
Table 3: This table's Primary Key will be a composite of Table 1 & 2's Primary Keys. Eg: C_ID+P_ID. The issue is that I don't want to first make C_ID and P_ID foreign keys in Table 3, I want to use them directly in a composite key.

This is on an Oracle 10g server btw. Any help would be much appreciated, searching online has proven fruitless.

Thanks in advance,
- Peter