Friday, September 20, 2013

Best mapping technique using Operator Precedence

If there is a  condition you want to map one to many or many to one  scenario in you program.
Program can be a
database table,
selection box in you web page,
posting data to server

For example:
There is a condition student and course you want to map and store or send some where.

The way engineers do 





The way of doing using Operator Precedence 









According to the table in old way: 
Tiru - Joined Course (Java,C,C++)
John- Joined Course (Java)
Kotini- Joined Course (Java,C++,Android,Python)

How it Operator Precedence works
Assign some unique bit as Course Bit Id.
What ever student -course mapping value store in Student Table's Student Course Column 

Tiru - Joined Course (Java,C,C++)
i.e 
Tiru-Do operator or for Tiru's courses  (1|10|100=111)

John- Joined Course (Java)
i.e 
John-Do operator or for John's courses  (1=1)

Kotini- Joined Course (Java,C++,Android,Python)
i.e 
Kotini-Do operator or for Kotini's courses  (1|100|1000|10000=11101)

How to check actual student course in  from [Student Course Column]

If you retrieved Kotini's courses i.e 11101
then check using operator  and
11101&1=1 (11101&Java=Java)
11101&10=0 (11101&C=0 means Kotini not joined in C)
11101&100=100 (11101&C++=C++)
11101&1000=1000 (11101&Android=Android)
11101&10000=10000 (11101&Python=Python)

How to check remove a student course in  from [Student Course Column]
Kotini's courses  (11101=Java,C++,Android,Python) and if you want to remove C++ i.e 100 course 
then check using operator  '-'
11101-100=11001=Java,Android,Python


What is the advantage of this technique 
 As we know bit wise operation is the fastest operation.And less memory usage.
In this example we decreased a table. 

Where this technique currently using.
1>In Microsoft Office Excel,Word,Power Point
2>In Some html Multi Selection





1 comment:

  1. Good going .
    Keep Posting.
    Please explain some more details with one or two examples.

    ReplyDelete