i have a POSTS table in postgres whose schema looks like below
create table posts(postid int ,postname VARCHAR(255) NOT NULL,
createdby VARCHAR(255) NOT NULL, PRIMARY KEY (postname),
CONSTRAINT fk_user FOREIGN KEY(createdby) REFERENCES users(username) on DELETE CASCADE);
maybe a noob question but i dont want the postid to be always set by the user, i want it to be incremental to a user. lets say for example i have 2 users each of whom are adding 2 posts,
so i want to store that in db as
postid. postname. createdby
1 hi user1
2 second user1
1 hi user2
2 second user2
is something like this possible for the postid to get autoincremented without me having to insert it that way?
i.e a postid and name can be similar to different users