-- 20014931.120
ALTER TABLE CUSTOMER ADD (
OTHERCUSTOMER_ID   NUMBER NULL);

ALTER TABLE CUSTOMER
ADD CONSTRAINT CUSTOMERRELATED_valid CHECK (CUSTOMERRELATED IN (0, 1, 2, 3, 4, 5));

ALTER TABLE CUSTOMER
ADD CONSTRAINT CUSTOMER_OTHERCUST FOREIGN KEY (OTHERCUSTOMER_ID) REFERENCES CUSTOMER (CUSTOMER_ID) ON DELETE SET NULL;

COMMENT ON COLUMN CUSTOMER.CUSTOMERRELATED
  IS '0=Not applicable
1=Related to this customer
2=Related to bill to customer (only valid when bill to customer <> customer)
3=Related to master account (only valid if customer is connected to master account)
4=Related to common customer (only valid if customer is connected to common customer)
5=Related to other customer (only valid if customer is connected to other customer)
';
