Обсуждение: FK question

Поиск
Список
Период
Сортировка

FK question

От
"Igor Kryltsov"
Дата:
Hi,

What is a difference, if any, between:
_________________________________
ALTER TABLE ONLY employee_role
    ADD CONSTRAINT fk_survey_id_employee_id FOREIGN KEY (survey_id,
employee_id) REFERENCES employee_survey(survey_id, employee_id) MATCH FULL
ON UPDATE C
ASCADE ON DELETE CASCADE;
__________________________________

AND
___________________________________
ALTER TABLE ONLY employee_role
    ADD CONSTRAINT fk_survey_id FOREIGN KEY (survey_id) REFERENCES
employee_survey(survey_id) MATCH FULL ON UPDATE C
ASCADE ON DELETE CASCADE;

ALTER TABLE ONLY employee_role
    ADD CONSTRAINT fk_employee_id FOREIGN KEY (employee_id) REFERENCES
employee_survey(employee_id) MATCH FULL ON UPDATE C
ASCADE ON DELETE CASCADE;
_____________________________________


Thank you,


Igor



Re: FK question

От
Martijn van Oosterhout
Дата:
The second will allow combinations of (survey_id,employee_id) that are
not in employee_survey as long as the individual survey_id and
employee_id's exist. Whether that's a problem or not depends on your
schema....

On Thu, Aug 26, 2004 at 04:48:12PM +1000, Igor Kryltsov wrote:
> Hi,
>
> What is a difference, if any, between:
> _________________________________
> ALTER TABLE ONLY employee_role
>     ADD CONSTRAINT fk_survey_id_employee_id FOREIGN KEY (survey_id,
> employee_id) REFERENCES employee_survey(survey_id, employee_id) MATCH FULL
> ON UPDATE C
> ASCADE ON DELETE CASCADE;
> __________________________________
>
> AND
> ___________________________________
> ALTER TABLE ONLY employee_role
>     ADD CONSTRAINT fk_survey_id FOREIGN KEY (survey_id) REFERENCES
> employee_survey(survey_id) MATCH FULL ON UPDATE C
> ASCADE ON DELETE CASCADE;
>
> ALTER TABLE ONLY employee_role
>     ADD CONSTRAINT fk_employee_id FOREIGN KEY (employee_id) REFERENCES
> employee_survey(employee_id) MATCH FULL ON UPDATE C
> ASCADE ON DELETE CASCADE;
> _____________________________________
>
>
> Thank you,
>
>
> Igor
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

Вложения