I have a table which has 3 foreign keys, two of which form the primary key.
I have: ID_Product, ID_Sale, ID_Buy, and also an attribute which tells if its a buy or a sale.
So, if a sale is made, the primry key should consist of ID_Product && ID_Sale, otherwise, it's ID_Product && ID_Buy.
Is there a way to do this in Oracle, and if there is, can you point me to where I can read about this?
thank you in advance
One table - one primary key. So - you're out of luck.
However, why do you need both ID_SALE and ID_BUY when there's another attribute which determines whether it is a sale or a buy? Why wouldn't you get rid of one of them (so that you'd have a primary key consisted of ID_PRODUCT + ID_SALE_BUY)?
Or, if you still need three ID columns, why wouldn't this primary key be composed of all three columns? Nothing references these columns (but they reference other primary keys; at least, that's what I understood). If row that has ID_SALE filled with a value and, at the same time ID_BUY is empty (i.e. NULL), primary key is out of question - but you'd probably be able to create UNIQUE key instead.