Hi, I have a table that references itself to create a tree-like structure,
eg:
CREATE TABLE tree (
id SERIAL NOT NULL,
name VARCHAR(255) NOT NULL,
parent INT NULL,
customer IN NOT NULL,
CONSTRAINT parent_key...
CONSTRAINT customer_fk FOREIGN KEY (customer) REFERENCES customer
);
ALTER TABLE tree ADD CONSTRAINT FOREIGN KEY (parent) REFERENCES tree;
As you can see tree also references the customer table.
What I need is a CHECK that will ensuer that any given "tree" row has the
same customer as its parent.
Remember that "parent" can also be NULL.
Or would this be better done as a trigger?
TIA!
========================================
Luke Pascoe
KMG (NZ) Limited. http://www.kmg.co.nz
Mobile: (021) 303019
Email: [EMAIL PROTECTED]
========================================
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]