PK, FK and Relationships

I have a database my tables are


primary key is pID

primary key is bID
foreign key is pID

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.

more ▼

asked Dec 27, 2010 at 05:31 AM in Default

avatar image

205 19 21 25

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

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?

more ▼

answered Dec 27, 2010 at 05:46 AM

avatar image

Fatherjack ♦♦
43.8k 79 101 118

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.

Dec 27, 2010 at 06:01 AM Magnus Ahlkvist

Yes, I will have contractor connected to more then one project. Do you mean contractor to project

Dec 27, 2010 at 06:02 AM postonoh

sorry, yes, was on phone and couldnt see Q as I wrote A . . . memory sadly affected by Christmas excesses.

Dec 28, 2010 at 01:02 AM Fatherjack ♦♦
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Dec 27, 2010 at 05:31 AM

Seen: 2021 times

Last Updated: Dec 27, 2010 at 05:42 AM

Copyright 2018 Redgate Software. Privacy Policy