My Problem is in a table i have 4 reference of the user ID
- Owner ID
- Assigner ID
- Taker ID
- Evaluator ID
- Final Evaluator ID
& all these column values are FK to开发者_开发问答 User detail table where i am having there name. If i want to have there name along with their ID while retrivieng the complete row I am joining 4 times with the user details table.
Is there any better Way
Thanks
If you are using it multiple times consider creating a view - it will save some time
That is the right way to do it.
If you want to make life easier for yourself you can use an abstraction layer on top of SQL, such as LINQ to SQL. This can be set up to create the joins for you automatically based on the foreign key constraints. But if you are writing directly in SQL then you have to write the joins yourself.
精彩评论