I've got 4 different tables and I want to delete one row, but it says: id is still referenced from table "parts". How to delete from table Car specific car (for example with id=10) and delete all data without dropping all tables and data? I created tables with Delete Restrict.
Table Car:
variables
Table Repair:
variables,
car_id integer NOT NULL REFERENCES car(id) ON UPDATE CASCADE ON DELETE RESTRICT
Table Parts:
variables,
repair_id integer NOT NULL REFERENCES repair(id) ON UPDATE CASCADE ON DELETE RESTRICT
Table Shop:
variables, part_id integer NOT NULL REFERENCES part(id) ON UPDATE CASCADE ON DELETE RESTRICT
you set yourself ON DELETE RESTRICT , so it restricts deletion if still referenced. You have to in transaction drop existing FK add new with REFERENCES car(id) ON UPDATE CASCADE ON DELETE CASCADE then you will be able to delete cascaded...