Can Postgres raise warnings if joins are inconsistant with foreign keys? Like most relational databases, PostgreSQL provides foreign keys as a means of providing referential integrity

CREATE TABLE job (
  id serial NOT NULL PRIMARY KEY
)

CREATE TABLE jobtuning (
  id serial NOT NULL PRIMARY KEY,
  job_id integer REFERENCES job (id)
)

CREATE TABLE jobstep (
  id serial NOT NULL PRIMARY KEY,
  jobtuning_id integer REFERENCES jobtuning (id)
)


In a case such as this when an intermediate join table is used it becomes very easy to write a query which appears to work, but is wrong:

JOIN jobstep ON jobtuning_id=jobtuning.job_id


It should be:

JOIN jobstep js ON js.jobtuning_id=jobtuning.id


One of the strengths of SQL is the ability to form arbitrary relationships, but is it possible to ask Postgres to issue a warning when a join is written that is inconsistent with the way foreign keys or other constraints are defined?
No.  It is up to the developer/DBA to write sensible joins, in this regard PostgreSQL is just a slave that does what its master commands.

In any case, defining the boundary between joins that make sense and those that don't is not trivial.  If that column is there because of a denormalization, for example, then it perfectly makes sense in spite of a nonexistent foreign key.  You can always decrease the possibility for accidental misjoins by not naming the primary key column just id but jobstep_id, for example.

Also, when should it emit the warning?  When you hit it with a 1000 line SQL script, containing a hundred statements, out of which 20 contain 'inconsistent' joins?

All in all, this is rather a code review problem than anything else.