Click here to Skip to main content
15,915,869 members
Home / Discussions / Database
   

Database

 
AnswerRe: hi...How to store datas temp in database Pin
SHatchard5-Jul-07 0:24
SHatchard5-Jul-07 0:24 
AnswerRe: hi...How to store datas temp in database Pin
Leah_Garrett5-Jul-07 0:48
Leah_Garrett5-Jul-07 0:48 
QuestionSQL Database Backup Pin
allan.cawood4-Jul-07 23:27
allan.cawood4-Jul-07 23:27 
AnswerRe: SQL Database Backup Pin
Paul Conrad13-Jul-07 11:55
professionalPaul Conrad13-Jul-07 11:55 
GeneralRe: SQL Database Backup Pin
allan.cawood15-Jul-07 20:01
allan.cawood15-Jul-07 20:01 
GeneralRe: SQL Database Backup Pin
Paul Conrad15-Jul-07 20:11
professionalPaul Conrad15-Jul-07 20:11 
QuestionSDF files Pin
ShuklaGirish4-Jul-07 23:03
ShuklaGirish4-Jul-07 23:03 
QuestionComposite Primary keys - A question Pin
vagl4-Jul-07 23:00
vagl4-Jul-07 23:00 
Hi,

I have question on usage of composite primary keys. I know it is suggested not to use them for performance reasons (wide indexes). But when it comes to enforcing the integrity constraints, composite keys help me.

Scenario:
I have the following tables.
Projects and Employees.

These tables share a m:n relationship and there is an intermediary table called "ProjectAssignments" with the following structure.

ProjectID, EmployeeID, EmpRole, AssignedBy, AssignedOn. (Primary Key: ProjectID & EmployeeID)

Employees with reviewer role, review the tasks of their reviewees on the specified date. This is captured with the following structure.

ReviewID, ProjectID, EmployeeID_Reviewer, EmployeeID_Reviewee, ReviewDate, TaskDesc. (PrimaryKey: ReviewID)

I would like the design to enforce the constraint that reviewer and reviewee are on the same project. I have defined the foreign keys as follows.

FOREIGN KEY([PRJ_ID], [EMP_ID_Reviewee]) REFERENCES [dbo].[ProjectAssignments] ([AGN_PRJ_ID], [AGN_EMP_ID])
FOREIGN KEY([PRJ_ID], [EMP_ID_Reviewer]) REFERENCES [dbo].[ProjectAssignments] ([AGN_PRJ_ID], [AGN_EMP_ID])


Is this is a good design?

The other alternative I thought has the following design. But, this does not enforce the above mentioned constraint.

Table ProjectAssignments: AssignID, ProjectID, EmployeeID, EmpRole, AssignedBy, AssignedOn. (Primary Key: AssignID)
(Unique Constraint: ProjectID, EmployeeID)


Table ProjectReviews:
ReviewID, AssignID_Reviewer, AssignIDReviewee, ReviewDate, ReviewTask. (Primary Key: ReviewID)

Which one should I prefer and why? I Unsure | :~ Confused | :confused:



Thanks,
AGL
AnswerRe: Composite Primary keys - A question Pin
Michael Potter5-Jul-07 5:01
Michael Potter5-Jul-07 5:01 
GeneralRe: Composite Primary keys - A question Pin
vagl5-Jul-07 19:59
vagl5-Jul-07 19:59 
Questionsyntax error in insert into statement Pin
magedhv4-Jul-07 22:53
magedhv4-Jul-07 22:53 
AnswerRe: syntax error in insert into statement Pin
Krish - KP4-Jul-07 23:09
Krish - KP4-Jul-07 23:09 
QuestionImproving the database performance Pin
S.Rajeshwar4-Jul-07 22:21
S.Rajeshwar4-Jul-07 22:21 
AnswerRe: Improving the database performance Pin
Pete O'Hanlon4-Jul-07 22:32
mvePete O'Hanlon4-Jul-07 22:32 
AnswerRe: Improving the database performance Pin
N a v a n e e t h4-Jul-07 22:50
N a v a n e e t h4-Jul-07 22:50 
AnswerRe: Improving the database performance Pin
andyharman4-Jul-07 22:51
professionalandyharman4-Jul-07 22:51 
Questionsql stored procedure Pin
harithadotnet4-Jul-07 21:18
harithadotnet4-Jul-07 21:18 
AnswerRe: sql stored procedure Pin
Krish - KP4-Jul-07 21:24
Krish - KP4-Jul-07 21:24 
AnswerRe: sql stored procedure Pin
N a v a n e e t h4-Jul-07 22:24
N a v a n e e t h4-Jul-07 22:24 
QuestionHave problem with displaying columns as rows Pin
masyarial4-Jul-07 20:35
masyarial4-Jul-07 20:35 
AnswerRe: Have problem with displaying columns as rows Pin
Krish - KP4-Jul-07 21:22
Krish - KP4-Jul-07 21:22 
GeneralRe: Have problem with displaying columns as rows Pin
masyarial5-Jul-07 1:39
masyarial5-Jul-07 1:39 
GeneralRe: Have problem with displaying columns as rows Pin
Krish - KP9-Jul-07 22:23
Krish - KP9-Jul-07 22:23 
GeneralRe: Have problem with displaying columns as rows Pin
masyarial10-Jul-07 1:09
masyarial10-Jul-07 1:09 
GeneralRe: Have problem with displaying columns as rows Pin
Krish - KP10-Jul-07 17:33
Krish - KP10-Jul-07 17:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.