How can I move a field from a the one table to the many table in a one-to-many relationship?
In our system we have a field that stores the address for an entire order (one ‘Order’ has many ‘OrderLineItems’). We now need to allow each ‘OrderLineItem’ in an order to store an address. For all orders up to this point everything was under one address so my idea was to simply set the address of each OrderLineItem to the address of its order.
- We are using MySQL 5.5.17
- Address is not a Foreign Key
Not much detail in the question. What which sql server are you using?
Is the address column a foreign key? What data type is it?
Do this in SQL Server for each address column, replacing
address_col_namewith the actual column name and specifying any constraints. Execute statements one at a time:There may be many other considerations but that is the basic code.