postgresql – Efficiently find the ultimate parent in multilevel one-to-many tables

Suppose I have a database of multilevel one-to-many tables (a fictitious example):

CREATE TABLE users (
  id SERIAL PRIMARY KEY
);

CREATE TABLE properties (
  id SERIAL PRIMARY KEY,
  user_id INTEGER NOT NULL REFERENCES users(id)
);

CREATE TABLE rooms (
  id SERIAL PRIMARY KEY,
  property_id INTEGER NOT NULL REFERENCES properties(id)
)

CREATE TABLE rates (
  id SERIAL PRIMARY KEY,
  price INTEGER NOT NULL,
  room_id INTEGER NOT NULL REFERENCES rooms(id)
)

For example, suppose a user wants to update that price in the rates But I want to make sure that he is allowed to – d. H rate belongs to a room that belongs to one property that the user owns.

What would be the best / most efficient way to do this? Is there a way to add a deduced user_id Column to rates Table that is automatically filled when the rows are added to the table rates Table so I can use it later in a query like the following:

UPDATE rates SET price=100 WHERE (id=30) AND (user_id=1)`