Search Postgresql Archives

Bit-wise foreign keys

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey all,

I'm tossing an idea around again, namely using bit positions and values as foreign key references. Let's start with a bit of background information:

I'm currently parsing a log-file that I want to apply all kinds of statistical analysis to. This file contains lines of records of data, among which are some bytes of which each bit marks a certain truth-value. As an internal data-object that's just dandy, but presenting it to, for example a user, or to query it for certain masks without having to delve into the definition of that particular bit-field it would be great to have a textual representation of each bit.

Let's say we have this byte, with the attached meanings:
  pos  meaning
   0   RED	(least significant bit)
   1   GREEN
   2   BLUE
   3   FIRE
   4   WATER
   5   EARTH
   7   AIR	(most significant bit)

Now if I see a value of 0x05, I know that this corresponds to [RED, FIRE] and if I have a value of 0x41 I know that I'm in trouble as there's a bit set that has no meaning!

Reeks of a foreign key constraint, doesn't it? An odd one though, as one value can contain multiple bits and thus references multiple foreign values...

Do we have anything for this yet? If not, would this be a good feature?
I imagine something similar could be done for (fixed-length?) arrays too...

Of course something like this would benefit from some convenience functions; you wouldn't really want to get multiple records for the same row with different bits matched - something like bit_accum() to turn the separate results into an array would be useful I think.

Alban Hertroys

--
If you can't see the forest for the trees,
cut the trees and you'll see there is no forest.


!DSPAM:737,4c97949110251883445726!



-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux