clear markdown compare help donate or buy diddy dollings comments/suggestions/bugs a leap of faith? bible365
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 818564 fiddles created (9202 in the last week).

select version();
version
PostgreSQL 10.9 (Debian 10.9-1.pgdg80+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 4.9.2-10+deb8u2) 4.9.2, 64-bit
 hidden batch(es)


CREATE TABLE member ( member_id INTEGER PRIMARY KEY, member_fname VARCHAR(15) NOT NULL, member_lname VARCHAR(15) NOT NULL, member_status VARCHAR(15) NOT NULL, member_address VARCHAR(10) NOT NULL, member_email VARCHAR(30) NOT NULL );
 hidden batch(es)


CREATE TABLE bicycle ( bicycle_id INTEGER PRIMARY KEY, bicycle_brand VARCHAR(25) NOT NULL, bicycle_model VARCHAR(25) NOT NULL, bicycle_colour VARCHAR(15) NOT NULL, bicycle_type VARCHAR(20) NOT NULL, bicycle_size VARCHAR(10) NOT NULL, bicycle_availability VARCHAR(20) NOT NULL );
 hidden batch(es)


CREATE TABLE rental ( rental_no INTEGER PRIMARY KEY, rental_period DATE NOT NULL, bicycle_pickup_date DATE NOT NULL );
 hidden batch(es)


CREATE TABLE company ( company_id INTEGER PRIMARY KEY, company_name VARCHAR(20) NOT NULL, company_contact VARCHAR(50) NOT NULL, company_address VARCHAR(50) NOT NULL );
 hidden batch(es)


CREATE TABLE sponsor ( sponsor_id INTEGER PRIMARY KEY, sponsor_name VARCHAR(15) NOT NULL, sponsor_contact VARCHAR(30) NOT NULL, sponsor_period DATE NOT NULL, sponsor_address VARCHAR(50) NOT NULL, sponsor_fee DECIMAL (6, 2) NOT NULL );
 hidden batch(es)


CREATE TABLE terminal ( terminal_id INTEGER PRIMARY KEY, terminal_address VARCHAR(50) NOT NULL, terminal_minstorage VARCHAR(50) NOT NULL, terminal_maxstorage VARCHAR(50) NOT NULL );
 hidden batch(es)


CREATE TABLE bill ( bill_id INTEGER PRIMARY KEY, bill_date DATE NOT NULL, bill_total_amount DECIMAL(6, 2) NOT NULL, payment_no INTEGER NOT NULL, payment_date DATE NOT NULL, payment_method VARCHAR(15) NOT NULL );
 hidden batch(es)


CREATE TABLE maintenance ( maintenance_id INTEGER PRIMARY KEY, bicycle_id INTEGER NOT NULL, maintenance_contact_person VARCHAR(15) NOT NULL, maintenance_phone_number INTEGER NOT NULL, maintenance_fee DECIMAL(6, 2) NOT NULL );
 hidden batch(es)


-- -- Foreign key defined without error -- ALTER TABLE maintenance ADD CONSTRAINT maint_bike_fk FOREIGN KEY (bicycle_id) REFERENCES bicycle (bicycle_id);
 hidden batch(es)


DROP TABLE maintenance;
 hidden batch(es)


CREATE TABLE maintenance ( maintenance_id INTEGER PRIMARY KEY, bicycle_id INTEGER NOT NULL, maintenance_contact_person VARCHAR(15) NOT NULL, maintenance_phone_number INTEGER NOT NULL, maintenance_fee DECIMAL(6, 2) NOT NULL, CONSTRAINT maint_bike_fk FOREIGN KEY (bicycle_id) REFERENCES bicycle (bicycle_id) );
 hidden batch(es)


-- -- First Error - first of your foreign keys defined -- ALTER TABLE bicycle ADD CONSTRAINT fk_bicycle_pickup_date FOREIGN KEY (bicycle_pickup_date) REFERENCES rental(bicycle_pickup_date);
ERROR: column "bicycle_pickup_date" referenced in foreign key constraint does not exist
 hidden batch(es)


ALTER TABLE bicycle ADD CONSTRAINT fk_maintenance_contact_person FOREIGN KEY (maintenance_contact_person) REFERENCES maintenance(maintenance_contact_person);
ERROR: column "maintenance_contact_person" referenced in foreign key constraint does not exist
 hidden batch(es)


ALTER TABLE bicycle ADD CONSTRAINT fk_terminal_id FOREIGN KEY (terminal_id) REFERENCES terminal(terminal_id);
ERROR: column "terminal_id" referenced in foreign key constraint does not exist
 hidden batch(es)


ALTER TABLE bicycle ADD CONSTRAINT fk_rental_period FOREIGN KEY (rental_period) REFERENCES rental(rental_period);
ERROR: column "rental_period" referenced in foreign key constraint does not exist
 hidden batch(es)