Explain the dangers of the sequence of statements in part a


Consider the following relational database schema:

CREATE TABLE ACCOUNTS
(
account_no char(12),
amount money,
CONSTRAINT PK_ACCOUNTS PRIMARY KEY(account_no)
)

CREATE TABLE PENDING_TRANSFERS
(
from_account_no char(12),
to_account_no char(12),
amount money,
CONSTRAINT PK_ PENDING_TRANSFERS PRIMARY KEY(from_account_no,
to_account_no),
CONSTRAINT FK_PENDING_TRANSFERS_FROM_ACCOUNT
FOREIGN KEY(from_account_no) REFERENCES ACCOUNTS(account_no),
CONSTRAINT FK_PENDING_TRANSFERS_TO_ACCOUNT
FOREIGN KEY(to_account_no) REFERENCES ACCOUNTS(account_no),
)

(a) Write three SQL statements: the first statement should add the pending amounts to the appropriate accounts, the second statement should subtract the pending amounts from the appropriate accounts, and the third statement should delete the pending balance transfer information.

(b) Explain the dangers of the sequence of statements in part (a) above, in terms of what would happen in case the database server or SQL interface were to crash in between two of these three statements.

(c) Show how to remove the dangers you described in part (b).

Solution Preview :

Prepared by a verified Expert
Database Management System: Explain the dangers of the sequence of statements in part a
Reference No:- TGS01258686

Now Priced at $20 (50% Discount)

Recommended (94%)

Rated (4.6/5)