Re: Foreign key to a partial key

From: Simon G <simonjgl(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Foreign key to a partial key
Date: 2014-03-09 17:28:34
Message-ID: CAH5GJU8LEoTLWtJoGiVGF0RVQF=Gr81-BwzBC6iuq4qs=kJZsw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello, David:

You are absolutely right.

I was wrong. Although the wbs_code is not a surrogate key, I was using it
like it was.
A product may have a wbs_code, but from a wbs_name, It cannot exists alone.
So wbs_name has to be included in the products table. My mistake.

Your solution is what needed to be done. A FK referencing projects (wbs_name,
project_id) ensures that the wbs_name used in the product is the proper
wbs_name of the project. I already tried it and it works.

Thank you very much.

Simon Graffe

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message ssylla 2014-03-18 12:22:39 problem with update order (?)
Previous Message David Johnston 2014-03-09 16:35:52 Re: Foreign key to a partial key