Hacker News new | ask | show | jobs
by torgard 1636 days ago
I dig it!

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.

2 comments

I've been quite happy having fully prefixed column names for a long time now. Makes joins easier, big views clearer, and random exports more readable out of the box. Also in my case it's also easier to line up unique column names with things like Clojure specs but I accept that's a niche concern.
Much cleaner, I agree, that's a big win. Will add that to the list of benefits.

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.