What is the correct order if I have to delete column O_CLIENT?
- Delete relation; then delete column O_CLIENT
- Delete column o_CLIENT
CREATE TABLE client (
C_ID int PRIMARY KEY AUTOINCREMENT,
....
);
CREATE TABLE order (
O_ID int PRIMARY KEY AUTOINCREMENT,
.......
O_CLIENT long FOREIGN KEY REFERENCES client(C_ID)
);
You have to delete the relationship first, or else you will end up with a foreign key constraint error. This is built in to protect you from having dangling references (ie. you delete client 1, but there are still 3 orders tied to client 1. If you try to get the client from the order, you will get nothing, which would be invalid)
You can also look into cascading deletes, so that the top level delete, deletes all of the relationships automatically. Then you can just perform one delete that clears everything out