I wonder why it is needed to put the (primary key = foreign key) in a where statement. Tables are related to each other via such criteria. So, why everybody use that in the where clauses or *join*s?
I mean instead of
select a.name, b.name
from a,b
where (a.fk = b.pk) AND (something = “something”)
if one says
…
select a.name, b.name
from a,b
where (something = “something”)
would it be enough?
First of all, not everyone uses foreign keys, unfortunately. Second of all, it shouldn’t be assumed that a parent table and child table should automatically be joined via the PK and FK of the respective tables, even though that is probably most common.
The folks on the SQL ANSI committee are pretty smart folks. I’m sure they’ve thought this all through and decided the current standard is the safest and most robust.
BTW, a very nice thing about Linq is that you don’t have to specify joins if the tables have the proper FKs defined. Assuming of course that you’re doing inner joins. And assuming you actually want to join on the PK and FK.