cbbrowne/Schemaverse — comment on commit 90fe164f08e267ebb9b4bcd994b28bfab03ee3a0
File: create_schemaverse.sql line 585
By cbbrowne:

I wonder if it *is* the right thing to "insert to my_ships."

It seems to me that this will require increasing amounts of cleverness as attributes get added.

I'm finding I want to do multiple inserts (e.g. - need INSERT INTO ship(), INSERT INTO ship_location (), possibly more...), which doesn't seem to work very well.

Probably what has to happen is for this to be refactored into some function calls.

Thus, something more like:

CREATE OR REPLACE RULE ship_insert AS ON INSERT TO my_ships DO INSTEAD
perform create_ship (parameters);

Suppose create_ship() returns the new ship ID, then we want...

perform locate_ship(create_ship(parameters), location);

That works if the ID is only used once. If there turn out to be two functions that require the ship ID, then it all has to get wrapped together. Perhaps that simply means that create_ship() does everything, and maybe there's no need for a trigger on ship.