From: svenax Date: 2006-10-12T18:05:07+09:00 Subject: Re: sets in SQL/Ruby surf wrote: > I have been working on building a common library that represents > fields as weighted sets. > Below is a code sample of how the sets are declared. The example is of > 3 different sets. > I map each set element as a name of the element to a symbol of length > one. Then the set is > stored in the database field as a char and a digit (since it's > weighted). I guess the main point here is the database representation. The solution you have given may be fine given that the data domain can be limited to those constraints (single char and single digit). You could increase this a bit by coding the weight and/or element to another base (i.e. using the full 256 byte values as representation). But then you loose readability if that is important. You could use a variable length encoding with a separator character, like so: element,12,another,4,bigone,12345 Or you could go the whole way and store a YAML representation of the data set in the database. That'd give you maximum flexibility, but depending on how the data is to be used may or may not be appropriate. -- Sven Axelsson