Databases and Deep Copy

If I want to make a deep copy of an object stored in my relational database, should I do something fundamentally wrong in the architecture? This is a different approach to another (much more detailed) question that I asked, but did not get a big answer to the call Copy data from a relational table .

+4
source share
4 answers

It depends on what your relational tables are, and which of your entities are grouped together to create a "business object." For example, if you have a relational model of a content management system with a Posting table and a Text_lines table, where each posting consists of a list of text strings, a valid copy of your Posting business object is likely to be a deep copy of the Posting entity "along with the owned Text_lines objects.

, "" "", ( , ). , . "" → "Text_lines" "ON DELETE CASCADE" (, ). "" → "" " ".

+1

. , . ( , , - ), .

, ; , . .

+2

, , , . , , . , , , , - .

+2
source

I believe that if you need a stable clone of a database object, it is best to do a deep copy - at least copy all those elements that may change at some point in the future. I don’t see that there are many alternatives besides introducing some kind of clone copy-to-write style, which, although it may be right in some cases, will lead to a whole host of additional logic and complexity.

+2
source

All Articles