In below tables, films table is a sub class of shows table. For every new row inserted (via web interface) into table shows I want to insert a row into films: For example,
INSERT INTO shows title VALUES ('title');
This will add a new row in shows with showid = next value in sequence, and title = 'title'... What I want is to get showid value (from shows) and insert it into new row in films table.
How can I do that?
CREATE SEQUENCE shows_showid_seq;
CREATE TABLE "shows" (
"showid" BIGINT NOT NULL PRIMARY KEY DEFAULT nextval('shows_showid_seq'),
"title" TEXT NOT NULL,
"rating" BIGINT,
"language" TEXT,
"genre" TEXT
);
CREATE TABLE "films" (
"showid" BIGINT NOT NULL CONSTRAINT films_showid
REFERENCES shows("showid") ON DELETE SET NULL,
"year" INT, "reldate" DATE
);