![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
[note that "3 feet" is different from "1 yard" -- even though they both might *resolve* to the same physical length] The first "problem" is to define a mechanism whereby I can enforce a particular "dimensioned type" on a column. So, I can define a column as "type length" and, thereafter, be assured that PG (with my mechanisms) enforces this constraint on all values entered into that column. |
|
I can come up with a representation that allows me to accurately preserve values as entered (e.g., noting that "3.0 feet", "36 inches", "1 yard" and "3 feet" are each *different* and need to be recalled as such) yet gives me some expediency in comparison operations (e.g., for sorting). |
|
I suspect twiddling the system tables is frowned upon? But, I could always create my *own* version of the system tables layered atop everything?? (sigh) Too early in the morning for this sort of thinking. My head hurts... :-( |
#3
| ||||||
| ||||||
|
|
On 2011-03-01, D Yuniskis<not.going.to.be (AT) seen (DOT) com> wrote: [note that "3 feet" is different from "1 yard" -- even though they both might *resolve* to the same physical length] The first "problem" is to define a mechanism whereby I can enforce a particular "dimensioned type" on a column. So, I can define a column as "type length" and, thereafter, be assured that PG (with my mechanisms) enforces this constraint on all values entered into that column. 1 way: check the value against the apropriate regular expression. |
|
another way: attempt to use 'units' or a similar program to convert the offered value into a chosen base type (eg: for length convert it to metres) |
|
I can come up with a representation that allows me to accurately preserve values as entered (e.g., noting that "3.0 feet", "36 inches", "1 yard" and "3 feet" are each *different* and need to be recalled as such) yet gives me some expediency in comparison operations (e.g., for sorting). something like 'units'? or design your own if you don't need obscure units like 'thomb' $ units 'three inch' mm * 76.2 A c function (or several) using libudunits might be the way to go. I have never used libudunits, 'units' does not use it either. |
|
I suspect twiddling the system tables is frowned upon? But, I could always create my *own* version of the system tables layered atop everything?? (sigh) Too early in the morning for this sort of thinking. My head hurts... :-( just create several new type of text and new comparison operators that convert to a base type before comparing. |
|
absolute temperature will need a to be different type to relative temperature. |
|
units takes " as seconds of arc rather than as inches, but it may be possible to force libudunits to do what you want. |
#4
| |||||
| |||||
|
|
Hi Jasen, The first "problem" is to define a mechanism whereby I can enforce a particular "dimensioned type" on a column. So, I can define a column as "type length" and, thereafter, be assured that PG (with my mechanisms) enforces this constraint on all values entered into that column. another way: attempt to use 'units' or a similar program to convert the offered value into a chosen base type (eg: for length convert it to metres) I don't resolve an expression to a "real" value because this throws away information. E.g., "3" and "3.000" are different as are "12 inches" and "1 foot" (neglecting the ambiguity in determining *which* "foot" is meant, here). |
|
I thought I could possibly store an *approximation* of a "real value" as an *interval* (i.e., (min,max) range) and use that to expedite comparisons. So, the compare operator that I would have to write for the type could do something like: |
|
if (a.min > b.max) return A_GREATER_THAN_B else if (a.max < b.min) return A_LESS_THAN_B else /* ranges overlap so more expensive test required */ and *hope* that the early tests handle most comparisons. |
|
I can come up with a representation that allows me to accurately preserve values as entered (e.g., noting that "3.0 feet", "36 inches", "1 yard" and "3 feet" are each *different* and need to be recalled as such) yet gives me some expediency in comparison operations (e.g., for sorting). something like 'units'? or design your own if you don't need obscure units like 'thomb' $ units 'three inch' mm * 76.2 A c function (or several) using libudunits might be the way to go. I have never used libudunits, 'units' does not use it either. These all force binding the expression to a real value before storing it. See above |
|
just create several new type of text and new comparison operators that convert to a base type before comparing. If I restrict the type to just a special "text", then I lose the possibility of any optimizations for comparisons, etc. (because there are no other "members" in the type that I can stuff information into -- like "(min, max)" alluded to above) |
#5
| |||||
| |||||
|
|
On 2011-03-10, D Yuniskis<not.going.to.be (AT) seen (DOT) com> wrote: Hi Jasen, The first "problem" is to define a mechanism whereby I can enforce a particular "dimensioned type" on a column. So, I can define a column as "type length" and, thereafter, be assured that PG (with my mechanisms) enforces this constraint on all values entered into that column. another way: attempt to use 'units' or a similar program to convert the offered value into a chosen base type (eg: for length convert it to metres) I don't resolve an expression to a "real" value because this throws away information. E.g., "3" and "3.000" are different as are "12 inches" and "1 foot" (neglecting the ambiguity in determining *which* "foot" is meant, here). what I mean is attempt the conversion, and if that's successful the expression is valid |
|
I thought I could possibly store an *approximation* of a "real value" as an *interval* (i.e., (min,max) range) and use that to expedite comparisons. So, the compare operator that I would have to write for the type could do something like: floating-point types are by definition approximations. |
|
if (a.min> b.max) return A_GREATER_THAN_B else if (a.max< b.min) return A_LESS_THAN_B else /* ranges overlap so more expensive test required */ and *hope* that the early tests handle most comparisons. where are you getting min and max from ? |
|
I can come up with a representation that allows me to accurately preserve values as entered (e.g., noting that "3.0 feet", "36 inches", "1 yard" and "3 feet" are each *different* and need to be recalled as such) yet gives me some expediency in comparison operations (e.g., for sorting). something like 'units'? or design your own if you don't need obscure units like 'thomb' $ units 'three inch' mm * 76.2 A c function (or several) using libudunits might be the way to go. I have never used libudunits, 'units' does not use it either. These all force binding the expression to a real value before storing it. See above no they don't. store the string, use units for the comparison. $ units "6 miles - 10 kilometres" Definition: -343.936 m negative result means '10 kilometres'> '6 miles' |
|
just create several new type of text and new comparison operators that convert to a base type before comparing. If I restrict the type to just a special "text", then I lose the possibility of any optimizations for comparisons, etc. (because there are no other "members" in the type that I can stuff information into -- like "(min, max)" alluded to above) Why do you need "(min, max)"? the precision of a double precision float exceeds the capability of all common measuring aparatus. |
![]() |
| Thread Tools | |
| Display Modes | |
| |