On Sunday 24. January 2010 16.22.00 Wayne E. Pfeffer wrote:
> If you do not use null to represent a root node, when you go to unwind the
> data from the table to generate a hierarchy tree, you could end up with an
> infinite loop. The query will always be looking for the next parent in the
> hierar
If you do not use null to represent a root node, when you go to unwind the
data from the table to generate a hierarchy tree, you could end up with an
infinite loop. The query will always be looking for the next parent in the
hierarchy. Meaning, you will want to find the parent of a node using the
g
Xi Shen wrote:
> what if you insert other values like '1', '999'? will the insertion
> successful? if so, what's the difference between a deferred reference
> and no reference at all?
Nice question ;-)
Okay, recreate the table but without NOT NULL:
test=# CREATE TABLE refers ( id SERIAL PRIMA
What is the preferred way to enforce that there is at least one orphan
record if any at all, and that a record is not a Marty McFly type
descendent of itself? I would suggest that a statement level after
trigger is the way to go, but I myself have never actually had to
enforce this.
Regards,
Peter
On Sun, Jan 24, 2010 at 10:36 PM, Andreas Kretschmer
wrote:
> Ovid wrote:
>
>> Assuming I have the following table:
>>
>> CREATE TABLE refers (
>> id SERIAL PRIMARY KEY,
>> name VARCHAR(255) NOT NULL,
>> parent_id INTEGER NOT NULL,
>> FOREIGN KEY (parent_i
Xi Shen wrote:
> > To handle that you can set the constzraint deferrable, initially
> > deferred:
> >
> > test=# CREATE TABLE refers ( id SERIAL PRIMARY KEY, name VARCHAR(255) NOT
> > NULL, parent_id INTEGER NOT NULL, FOREIGN KEY (parent_id) REFERENCES
> > refers(id) deferrable initially defer
Ovid wrote:
> Assuming I have the following table:
>
> CREATE TABLE refers (
> idSERIAL PRIMARY KEY,
> name VARCHAR(255) NOT NULL,
> parent_id INTEGER NOT NULL,
> FOREIGN KEY (parent_id) REFERENCES refers(id)
> );
> I need to insert two records so tha
Ovid wrote on 24.01.2010 14:43:
Assuming I have the following table:
CREATE TABLE refers (
idSERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
parent_id INTEGER NOT NULL,
FOREIGN KEY (parent_id) REFERENCES refers(id)
);
I need to insert two records
On 1/24/10 8:43 AM, Ovid wrote:
Assuming I have the following table:
CREATE TABLE refers (
idSERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
parent_id INTEGER NOT NULL,
FOREIGN KEY (parent_id) REFERENCES refers(id)
);
I need to insert two records
On Sunday 24. January 2010 14.43.10 Ovid wrote:
> Assuming I have the following table:
>
> CREATE TABLE refers (
> idSERIAL PRIMARY KEY,
> name VARCHAR(255) NOT NULL,
> parent_id INTEGER NOT NULL,
> FOREIGN KEY (parent_id) REFERENCES refers(id)
> );
> I
Assuming I have the following table:
CREATE TABLE refers (
idSERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
parent_id INTEGER NOT NULL,
FOREIGN KEY (parent_id) REFERENCES refers(id)
);
I need to insert two records so that "select * from refers" looks l
11 matches
Mail list logo