It is known what algorithms perform the task of updating the database by inserting, updating, and deleting rows in the presence of database restrictions?
In particular, let's say that before the images of the lines that need to be deleted, after the images of the inserted lines and by the two images of the lines that need to be updated, they are in memory. Rows can be for several tables. The exact sequence of updates is either unknown or has not been saved - only previous images and images are known after the database has to be made for reflection.
The database contains a primary key, a foreign key, and unique index restrictions. The problem is to find a sequence of commands to update the database. For simplicity, I’m ready to point out that the primary key of the string will never be changed.
The database system does not support pending constraint checking. (This solution is trivial for such databases). I also have to make a rule that columns of primary keys cannot be updated after insertion, and it is not allowed to delete a row and reinsert it with the same primary key, although some algorithms may otherwise find this convenient. (This is necessary for common scenarios where all primary keys are automatically generated by the database system.)
What are the algorithms:
, , №1 .
: - ( ) . , ORM .
, , .. .
:
, INSERT, UPDATE DELETE, .
. , .
, . , , .
, , .
" " - . , .
EDIT2:
RBarryYoung , ( ), № 1 №2. № 1, , . DELETE/UPDATE-INSERT №1, , , . , № 2, , № 2. .
, - . .
CREATE TABLE A
(
AId INT NOT NULL PRIMARY KEY
)
CREATE TABLE B
(
BId INT NOT NULL PRIMARY KEY,
AId INT NOT NULL FOREIGN KEY REFERENCES A (AId)
)
CREATE TABLE C
(
CId INT NOT NULL PRIMARY KEY,
AId INT NOT NULL FOREIGN KEY REFERENCES A (AId),
BId INT NOT NULL FOREIGN KEY REFERENCES B (BId)
)
:
A (1)
B (1,1)
C (1,1,1)
:
A (1)
B (2,1) [To be deleted: (1,1)]
C (1,1,2)
: A, B, C
- DELETE B (1,1), - C (1,1,1).
, C NULL ( ), NULLing , №2. . , , .