Simple way to store lots of boolean data

Miklos_Hollender
Member Posts: 1,598
As an idea that occured to me in this topic: http://www.mibuso.com/forum/viewtopic.php?t=13671
If you have lots of boolean, yes/no information, you don't need to create a field for each of them, you can also store them all in one integer, by borrowing the idea from Unix security.
For example, you have information that looks like false, false, true, false, true. You can write it as 00101 which is a binary number, and in decimal it is 5. (1 times 2 power 0 + 1 times 2 power 2) So you can store each combination as an integer value.
For example, this is how Microsoft CRM stores security, like, you can edit a given record (true) but not delete it (false).
If you have lots of boolean, yes/no information, you don't need to create a field for each of them, you can also store them all in one integer, by borrowing the idea from Unix security.
For example, you have information that looks like false, false, true, false, true. You can write it as 00101 which is a binary number, and in decimal it is 5. (1 times 2 power 0 + 1 times 2 power 2) So you can store each combination as an integer value.
For example, this is how Microsoft CRM stores security, like, you can edit a given record (true) but not delete it (false).
0
Comments
-
True, good tip!
Only problem I can think of it that you need to recaclulate the values and maybe even change code if you want to add a new filtervalue.0 -
This is what the BitVector32 Structure in .NET does.
You can access each invidual bit of a 4 byte int (32 bits). You can make each bit significant in it's own way and use a mask to determine which bits are on and which are off.
If someone wants to wrap this structure or reimplement it in Navision (using some funky binary maths) then that would probably be a way to go to achieve this functionality. (or use BlackTiger's approach which is just as feasible, if not simpler!!)This isn't a signature, I type this at the bottom of every message0 -
That's also a solution.
Have you ever tested the performance of filtering with ??? in the filter?0 -
BlackTiger,
Yes, no filtering in the usual way. It's rather useful for security, for deciding what a given user can do with a given record/file, this is why MSCRM/Unix is using it. In the topic I linked above, the guy who opened it asked about security filters, and this gave me the idea.
P.S. Last week I signed a contract in the UK with the help of Steve D., the guy we both know. He really has good contacts...0 -
-
You'll need to change you flag
Nope. That reflects my nationality, not my location. I changed my location, that should be enough0 -
Good luck from me too ! I hope you have made the right choice.Kai Kowalewski0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions