CREATE TABLE business(
	businessid int,
	businessname text,
	constraint business_businessid_pk primary key (businessid)
);

create table batch(
	batchid int,
	businessid int,
	bid numeric,
	constraint batch_batchid_pk primary key (batchid),
	constraint batch_businessid_fk foreign key (businessid) references business(businessid)
);

create table regplate(
	licenceid int,
	licenceplate text,
	price numeric,
	batchid int,
	constraint regplate_licenceid_pk primary key (licenceid),
	constraint regplate_batchid_fk foreign key (batchid) references batch(batchid),
	constraint regplate_licenceplate_unique Unique (licenceplate)
);

INSERT INTO business(businessid, businessname) VALUES
(1, 'Toyota'),
(2, 'Renault'),
(3, 'Daves Autos'),
(4, 'Mercedes'),
(5, 'BMW'),
(6, 'Ferrari');
