Set
A set is a data type that consists of predefined values. It is similar to the ENUM data type, but a constant or variable defined as a set can store multiple values listed in the set declaration instead of just one.
A set can be defined in the source code of a program or in a database table structure. For example, a set that stores different types of sports may be declared in Python as follows:
set Sports { "soccer", "baseball", "tennis", "golf" };
Similarly, a column in a MySQL database table may be defined like this:
Sports SET ('soccer', 'baseball', 'tennis', 'golf')
A variable or database value defined as Sports can be assigned one or more of the four sports listed above. Therefore, it would make sense to create the Sports variable as a set if it is likely to contain multiple values. One example is a web form that asks a user to select sports that he or she likes to play. Since the user can choose one or more of the predefined values, the resulting data should be stored as a set. If the form were to ask the user to choose his or her favorite sport, the variable should be declared as an enum instead.
Like enums, sets can be used to ensure data integrity by limiting the values a variable or database record can store. However, this also makes sets less flexible than string or float data types. Therefore sets are appropriate for data types that only contain a limited number of values.