CREATE TABLE users
(
	userid int, --Linked to sequence users_userid_seq that starts at 1 and increments by 1.
	username text,

	CONSTRAINT users_userid_pk PRIMARY KEY (userid)
);

CREATE TABLE batch
(
	batchno int, --Linked to sequence batch_batchno_seq that starts at 1 and increments by 1.
	userid int,

	CONSTRAINT batch_batchno_pk PRIMARY KEY (batchno),
	CONSTRAINT batch_userid_fk FOREIGN KEY (userid) REFERENCES users(userid)
);

CREATE TABLE regnum
(
	regnumid int, --Linked to sequence regnum_regnumid_seq that starts at 1 and increments by 1.
	regnum text,
	price numeric,
	isavailable boolean,
	batchno int,

	CONSTRAINT regnum_regnumid_pk PRIMARY KEY (regnumid),
	CONSTRAINT regnum_batchno_fk FOREIGN KEY (batchno) REFERENCES batch(batchno),
	CONSTRAINT regnum_regnum_unique UNIQUE (regnum)
);

-- -- Use this insert statement to add users to the database to then be displayed in HTML.
-- INSERT INTO users (username)
-- VALUES ('EdwardPrasad'),
-- 			 ('JohnDoe');
