??????4.2????????ó???????????Schema??????

??????4.3????????????????Ч???

??????????????????????????????????罫?????Customer.Balance?????Account.Balance??????????λ???????????????????????

??????4.4???????????????

?????? ????????Schema??

???????????????????????Account.Balance?к?????????????SynchronizeAccountBalance??SynchronizeCustomerBalance??

?????????μ?DDL????

ALTER TABLE Account ADD Balance Numeric;
COMMENT ON Account.Balance 'Move of Customer.Balance column?? finaldate=2006-06-14';
CREATE OR REPLACE TRIGGER SynchronizeCustomerBalance
  BEFORE INSERT OR UPDATE
  ON Account
  REFERENCE OLD AS OLD NEW AS NEW
  FOR EACH ROW
  DECLARE
  BEGIN
    IF :NEW.Balance IS NOT NULL THEN
      UpdateCustomerBalance;
    END IF
  END;
/
COMMENT ON SynchronizeCustomerBalance 'Move of Customer.Balance column to Account??
dropdate = 2006-06-14';
CREATE OR REPLACE TRIGGER SynchronizeAccountBalance
  BEFORE INSERT OR UPDATE OR DELETE
  ON Customer
  REFERENCE OLD AS OLD NEW AS NEW
  FOR EACH ROW
  DECLARE
  BEGIN
    IF DELETING THEN
      DeleteCustomerIfAccountNotFound;
    END IF
    IF (UPDATING OR INSERTING) THEN
      IF :NEW.Balance IS NOT NULL THEN
        UpdateAccountBalanceForCustomer;
      END IF;
    END IF;
  END;
/
COMMENT ON SynchronizeAccountBalance 'Move of Customer.Balance column to Account?? dropdate=2006-06-14'