• In SQL you have several options to associate a set with a row for a multi-valued attribute of an entity. The most obvious solution is a separate table that stores a foreign key to the original row along with a single (reference to a) value of the attribute in each row. You can add an XML column and store several attribute values inside it (even for different attributes) but storing and retrieving their value introduces some overhead and additional complexity to your queries. If the number of values for a single row is rather limited, a numbered column collection is also an option ([TelNr_1], [TelNr_2], [TelNr_3], ...) though I would personally never recommend this solution. If the total number of possible values is very limited you might use a bitmap where each bit represents a value and that bit is set if the multi-valued attribute contains that value. A separate table should map the individual bits to the actual values.

    If you can live with the limitations of a bitmap (no foreign key and at most 64 values) it will save some storage but more important it allows you to do all kinds of set operations using simple bitwise operations. Checking wether the intersection of two sets is not empty requires no more than a bitwise and and a comparison. A bitwise or creates the union of two sets, an exclusive or the symmetric difference and an and with a not the difference. Allowing fast set operations makes these bitmaps extremely useful in authorization schemes. You should add the bitmap to your tool belt but use it with care, because it obscures the actual relations between tables and might cause serious trouble as soon as the number of possible values (roles for example) suddenly grows above that magic limit of 64.

    Although there is no physical relation between the table with the bitmap attribute and the table that maps the individual bits (guarded by a foreign key), a logical relation between these tables does exist. Fortunately SQL Server allows us to define any join predicate we like, so instead of an eqi-join we may use a bitwise and as well: [OriginalTable] INNER JOIN [ValueTable] ON ([OriginalTable].[Bitmap] & [ValueTable].[IndividualBit]) <> 0. A subquery with a FOR XML clause and a few REPLACEs around it can turn your bitmap into a human-readable comma-separated list of attribute values.