Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

The data melting pot

Building a business-to-business application with XML

-- Table CREDITORS
CREATE TABLE CREDITORS (
  CREDITOR_ID                NUMBER NOT NULL,
  CREDITOR                   VARCHAR2(20) NOT NULL
 )
/
-- Indexes for CREDITORS
CREATE  UNIQUE INDEX cd$creditor_id$pk
 ON CREDITORS (CREDITOR_ID)
/
-- Constraints for CREDITORS
ALTER TABLE CREDITORS
 ADD CONSTRAINT cd$creditor_id$pk PRIMARY KEY (CREDITOR_ID)
/

-- Table DEBTORS
CREATE TABLE DEBTORS (
  DEBTOR_ID                  NUMBER NOT NULL,
  FIRST_NAME                 VARCHAR2(15) NOT NULL,
  LAST_NAME                  VARCHAR2(25) NOT NULL
 )
/
-- Indexes for DEBTORS
CREATE  UNIQUE INDEX db$debtor_id$pk
 ON DEBTORS (DEBTOR_ID)
/
-- Constraints for DEBTORS
ALTER TABLE DEBTORS
 ADD CONSTRAINT db$debtor_id$pk PRIMARY KEY (DEBTOR_ID)
/

-- Table DEBTS
CREATE TABLE DEBTS (
  DEBTOR_ID                  NUMBER NOT NULL,
  CREDITOR_ID                NUMBER NOT NULL,
  BALANCE                    NUMBER(8,2) DEFAULT 0.00 NOT NULL,
  REMAINING_CREDIT           NUMBER(8,2) DEFAULT 0.00 NOT NULL
 )
/
-- Constraints for DEBTS
ALTER TABLE DEBTS
 ADD CONSTRAINT ds$creditor_id$fk FOREIGN KEY (CREDITOR_ID)
      REFERENCES CREDITORS(CREDITOR_ID) ON DELETE CASCADE
/
ALTER TABLE DEBTS
 ADD CONSTRAINT ds$debtor_id$fk FOREIGN KEY (DEBTOR_ID)
      REFERENCES DEBTORS(DEBTOR_ID) ON DELETE CASCADE
/