For the first step, we create a view named v_pgbench_accounts_self_join on pg-primary that uses the same columns and the same self-join we attempted in the previous recipe. Then, we grant access to bench_user so that the view is usable on the pg-report server.
Next, we create a foreign table just as we did in the Creating a foreign table recipe, but this time, we name the local foreign table pgbench_accounts_self even though the view has a much different name. This should illustrate that names do not have to necessarily match and that PostgreSQL doesn't care whether the remote object is a table or a view. Once again, we grant access to the foreign table to the mapped bench_user user and consider our work complete.
Before we ...