It's on the responcibility of an application programmer to
take care of the consistency of the
transactions: each committed transaction should preserve the consistency of the database.
If some consistency constraint (typically key- anf foreign key constraints) are defined in the schema,
the database managemnet system must guarantee that the constraints are not violated.
What control activities are needed and how should they be positioned
as copared to the actual operations of the transaction.
Consider key contraint and foreign key constraint.
Should these be included in the same transaction as the actual operations or
should there be a separate system transaction. What should be done if the transaction violates some constraint?
Consider table works_on works_on(personID->person,projectID->project, hours) and the transaction
begin;
insert into tyoskentely values (s1,p1,h1);
insert into tyoskentely values (s2, p2, h2);
insert into tyoskentely values (sn, pn, hn);
commit;
as an example.
When the system crashes the log has the following contents:
99: [checkpoint]
100: [start, T1]
101: [start, T2]
102: [write, T1, A, 10, 20]
103: [write, T2, B, 11, 22]
104: [commit, T1]
105: [start, T3]
106: [write, T3, A, 20, 30]
107: [abort, T2]
108: [checkpoint]
109: [start, T4]
110: [write, T3, B, 11, 33]
111: [write, T3, A, 30, 40]
112: [write, T4, C, 15, 25]
113: [commit, T3]
114: [write, T4, C, 25, 35]
- What operations must be done to recover the database when page of data element A
has PageLSN = 106, and the page of data element B has PageLSN = 110 and the page of data element C
has PageLSN = 112.
- What operations are needed if line 113 (T3-commit) is omitted?