>The PK of the master table and the PK of the detail table cannot be >the same thing, or they would not have a master-detail relationship. >One side has to be an FK, not a PK. > Of course this is correct. I was trying to make the point that there should be unique indices (of whatever flavor PG uses for PK's by default) on the relevant columns. Since we're referring to a select statement, the actual integrity constraints should not come into play. I will remember to be more explicit about the schema next time.