Hi,
I am bit confused over composite Primary key
For example
I have 2-table as fallows
1. 2.
SaleOrder SaleDetails
RecordNo, RecordNo,
RecordDate, RecordDate,
SalesType, SalesType,
CustomerId, SerialNo,
SaleAmount, ItemId,
FinancialYear, ItemAmount,
CompanyId, FinancialYear,
CompanyId,
My current composite primary key is applied on table SalesOrder
And on (RecordNo,SalesType,FinancialYear, CompanyId) which are
also present in 2nd table SalesDetails .
So every time when I required a particular record I have to apply join
SalesOrder and SalesDetails on each columns of composite primary key.
Is it a good idea to denormalized all these columns ? and addind new column Suppose.. (PKeyOrder = RecordNo+SalesType+FinancialYear+CompanyId),
And create a single primary key on newly added PKeyOrder column.
This will surely reduce no of joints but increases overheads on by tables,
Which is better solution.
Thanks,
Sandeep