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.

Updated November 25, 2015 by Per C.

Definitions by

The definition of Set on this page is an original definition. If you would like to reference this page or cite this definition, you can use the green citation links above.

The goal of is to explain computer terminology in a way that is easy to understand. We strive for simplicity and accuracy with every definition we publish. If you have feedback about the Set definition or would like to suggest a new technical term, please contact us.

Want to learn more tech terms? Subscribe to the daily or weekly newsletter and get featured terms and quizzes delivered to your inbox.

Sign up for the free TechTerms Newsletter

How often would you like to receive an email?

You can unsubscribe or change your frequency setting at any time using the links available in each email.

Questions? Please contact us.