Re: Guarenteeing ordering constraints - Mailing list pgsql-general

From Joris Dobbelsteen
Subject Re: Guarenteeing ordering constraints
Date
Msg-id 73427AD314CC364C8DF0FFF9C4D693FF5584@nehemiah.joris2k.local
Whole thread Raw
In response to Guarenteeing ordering constraints  ("Joris Dobbelsteen" <Joris@familiedobbelsteen.nl>)
List pgsql-general
>-----Original Message-----
>From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
>Sent: donderdag 22 februari 2007 17:16
>To: Joris Dobbelsteen
>Cc: pgsql-general@postgresql.org
>Subject: Re: [GENERAL] Guarenteeing ordering constraints
>
>"Joris Dobbelsteen" <Joris@familiedobbelsteen.nl> writes:
>> I have some trouble guarenteeing that an ordering constraint is
>> enforced on the database. On the table ordering (see below)
>I want to
>> enforce that for every tuple t, all tuples u where u.position <
>> t.position this implies u.cumvalue <= t.cumvalue.
>
>I can't think of any reasonable way to enforce that in SQL.
>Perhaps you should consider restructuring your tables in such
>a way that this behavior emerges from a constraint that is
>enforceable --- maybe the cumulative values should be a
>(materialized?) view on an underlying table that contains
>individual observations.

Mmm, it seems that I'm beyond the boundaries. I seem to have the habit
of wanting just a little more than is possible. Nevertheless this seemed
simple enough...

Of course there is no way to force the trigger to read all commited rows
and be waiting on the (possibly) required uncommitted ones? This may get
triggers closer to the constraints (like unqiue indexes and foreign
keys).
Seems triggers are more for business intelligence...

Thinking over the idea, I strongly believe restructing is going to cause
more trouble than anything else. Beyond that, there are now enough
constraints that I'm sure I cannot enforce anyways. That is, I cannot
even think about a good way to do it.
The current triggers will prevent bad things most of the time, but not
always. At this point that seems good enough for practical situations.

Example:
You have a printer, that's of some kind of model.
With the model you define what cartridges (colors) you can put in.
You can now replace a cartridge on a printer.
Of course you want to enforce that the color of the cartridge you
replace is valid.

Same problem, and I'm quite sure I cannot enforce it.

I believe something fundamental should change to ensure we can enforce
these constraints. At least, that would be a lot nicer.

- Joris

pgsql-general by date:

Previous
From: Tino Wildenhain
Date:
Subject: Re: php professional
Next
From: David Fetter
Date:
Subject: Re: how to generate a list of distinct scalar values from a column which type is array