Remove a foreign key from a server in production?

2

I have a cad_address table with my users' address record. I also have another request table mov_order that has a foreign key address_id for the address table, responsible for the relationship.

The problem is that when the face refreshes the address, it also updates the request address (due to the relationship). Because of this, we are creating a snapshot of the address in the order table, with all address data, now also in the request (a replica).

Now in the order status we will no longer search the customer's address for the relationship, but directly in the order table, then having the address that was registered at the time of purchase. We use the foreign key address_id , to migrate the data from the customer address to the order table.

However, we feel now that the order table has gotten a little dirty. The fact is, we have a column address_id , setting a relationship that is not being used for anything. And this relationship can confuse developers, not to mention that it can open a loophole for someone to do a little 'crap', call a relationship that is no longer being used ...

The question is: Is it correct to remove this column? Or should one keep it?

    
asked by anonymous 15.09.2016 / 00:50

1 answer

0

If you already have a replica of the data, remove the address_id column, as you yourself said, it does not add anything but can cause confusion with programmers.

In addition, you already have the order table related to the customer table which in turn is related to the addresses.

Note: It is important to advise customers that the delivery address can not be changed after purchase.

    
15.09.2016 / 01:08