I am creating a virtual cabinet in which I have many files say thousands. Each file can belong to one or more categories that is why In data base there should be a Bit mask through which the file can be retrieved. That mask should be a 32 bit binary number.
There are levels of the categories. All major categories have sub categories and those sub categories can also have sub sub categories. A file can belong to a sub category and it can also then belong to a major category. like if there is a major category A which have sub category B and Category B have a sub sub category C and there is another major category X which have a sub category Y and there is a file Z which belongs to the category Y and can belongs to category B.
Each category and sub category has also a bit mask ( 32 bit number) .As it is a 32 bit binary number there are 4 chunks of 8 bits . first chunk is for the major category second chunk of 8 bit is for sub category and 3rd chunk is for sub sub category and 4th one is for sub sub sub category . for the above example the bit mask would be

Category A = 00000000 00000000 00000000 00000001
Category B = 00000000 00000000 00000001 00000001
Category C = 00000000 00000001 00000001 00000001

Category X = 00000000 00000000 00000000 00000010
Category Y = 00000000 00000000 00000001 00000010

So from the mask C we can easily see that it belongs to a sub catogry B and it has a major category A

Now I would like to know that what would be a the bit mask of the file Z. which belongs to both the Y and B catgory.so that I can depict from where it belongs .

any suggestions would be appriciated