by torgard · 4y ago · 0 comments
I prefer defining tables like this:
CREATE TABLE category (
id int GENERATED ALWAYS AS IDENTITY,
name text
);
CREATE TABLE post (
id int GENERATED ALWAYS AS IDENTITY,
category_id int
REFERENCES category (id)
ON DELETE CASCADE
);
That is, category.id rather than category.category_id.
But the USING clause doesn't work with that style, as far as I understand.This would make my queries nicer.
Will also add a "Drawbacks / Remaining issues" section to the Gist, from all the valuable comments so far in this thread, thank you all, positive as well as negative comments, all very helpful.