question

postonoh avatar image
postonoh asked

PK, FK and Relationships

I have a database my tables are Project Bidpackage Contractor Project primary key is pID Bidpackage primary key is bID foreign key is pID Contractor primary key is cID foreign key is bID when a user select project it release the bidpackage base on the project and when a user select bidpackage it release only the contractors base on the bidpackage Here is my question. Did I set the foreign key relationship up right? I would like to now before I write the code for the make, model, year scenario.
sql-server-2008indexingprimary-keyforeign-key
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
Fatherjack avatar image
Fatherjack answered
What you have there seems fine, the project can have many bid and many contractors but bids and contractors can only relate to one project. If you should want something different - such as each contractor relating to more than one project then you will need a middle table to achieve the many-to-many relationship. Also, you currently have no relationship between the contractor and the bid. Does that fit your business rule?
3 comments
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

sorry, yes, was on phone and couldnt see Q as I wrote A . . . memory sadly affected by Christmas excesses.
1 Like 1 ·
It looks to me like there IS a relation between contractor and bid. In Contractor, there's a FK on bID, which I would assume relates to bID in bidpackage.
0 Likes 0 ·
Yes, I will have contractor connected to more then one project. Do you mean contractor to project
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.