SQL Bitwise Operations

I am hooked up bitwise for a new security paradigm I am creating called VMAC. Variable Matrix Access Control. I want to do boolean implication for bit strings. Just trying to avoid echoes (reinvent the wheel).

  • Before reinventing the wheel, is there an established shortcut to emulate -> (boolean implication) using AND and OR and NOT or other basic binary SQL statements?

  • XNOR will allow me to slice -> emulate up to four operations: NOT, XOR, OR and AND. But it is not widely available. Any known shortcuts for XNOR? I was thinking of something like AI operation on operands, and also NOTted oversights from the top of my head.

  • Any comments on the efficiency achieved by implementing bitwise data structures on a 64-bit platform, or the speed of multithreaded applications using parallel streams running on word-sized segments of a larger data object?

(Sorry, I'm not a computer scientist)

+1


source to share


4 answers


if A then B is logically equivalent (not A) or B



+2


source


If you are manipulating a bit string then

x -> y 

      

can be expressed in C / C ++ (or SQL) as:



~x | y

      

In terms of speed, the bitwise operators on a single machine word are incredibly fast as they are implemented in a single arithmetic instruction in the CPU. Achieving performance when doing math should be almost sloppy about the work of actually extracting the data.

+1


source


Any comments (3) on the efficiency achieved when implementing bitwise data structures on a 64-bit platform? Speed ​​in multi-threaded applications using parallel streams operating on word-sized segments of a larger data object?

I personally haven't thought much about this, but Raymond Chen has some comments.

These are just a few things to consider when considering whether to swap fields into bit fields. Bitfields save data memory, of course, but you have to balance that with the costs of code size, debuggability, and threading reduction. If your class will only be created a few times (and "a few" I think less than a few thousand times), then the cost is likely to outweigh the savings.

+1


source


The definition XNOR

is A * B +! A *! B

Therefore, in SQL it can be implemented like this:

DECLARE @A AS BIT;
DECLARE @B AS BIT;

(@A & @B) | (~@A & ~@B)

      

Alternative notation can be found here: http://michaelmairegger.wordpress.com/2011/10/14/sql-nand-xnor/

0


source







All Articles