What purpose would a primary key column serve on a table such as post_versions
here? Nothing refers to it, and there are no queries where I will ever want to select a row by post_versions.id
. It'll be joined to posts
in most queries.
CREATE TABLE posts ( id SERIAL PRIMARY KEY, created TIMESTAMPTZ NOT NULL DEFAULT now(), user_id INTEGER NOT NULL REFERENCES users ON DELETE RESTRICT);CREATE TABLE post_versions ( id SERIAL PRIMARY KEY, -- serves no purpose, could remove I think post_id INTEGER NOT NULL REFERENCES posts ON DELETE CASCADE, updated TIMESTAMPTZ NOT NULL DEFAULT now(), body TEXT NOT NULL);
Are there any problems if I just remove it?