Deleting rows from child table without deleting from parent
As you can see that is not the case, when  the tables are not linked in anyway


CREATE tABLE earthquakes_ovr (&quot;datetime&quot; timestamp)




INSERT INTO earthquakes_ovr VALUES (NOW() - INTERVAL '6 DAYS')




INSERT INTO earthquakes_ovr VALUES (now() - INTERVAL'4 days')




CREATE UNLOGGED TABLE  earthquakes AS SELECT * FROM earthquakes_ovr




    CREATE OR REPLACE FUNCTION earthquakes_trigger()
    RETURNS TRIGGER AS $$
    BEGIN
        INSERT INTO earthquakes VALUES (NEW.*);
        DELETE FROM ONLY earthquakes WHERE datetime &lt; (now() - '2 days'::interval);
        RETURN NEW;
    END;
    $$
    LANGUAGE plpgsql;
    
    CREATE TRIGGER earthquakes_trigger
            BEFORE INSERT ON earthquakes_ovr
            FOR EACH ROW EXECUTE PROCEDURE earthquakes_trigger();




INSERT INTO earthquakes_ovr VALUES (now())




SELECT * FROM earthquakes_ovr


| datetime                   |
| :------------------------- |
| 2021-04-18 00:11:15.191671 |
| 2021-04-20 00:11:15.203608 |
| 2021-04-24 00:11:15.267616 |




SELECT * FROM earthquakes


| datetime                   |
| :------------------------- |
| 2021-04-24 00:11:15.267616 |


db&lt;&gt;fiddle here