Home : Bits and Bytes : Set Definition


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

Cite this definition:


TechTerms - The Tech Terms Computer Dictionary

This page contains a technical definition of Set. It explains in computing terminology what Set means and is one of many computing terms in the TechTerms dictionary.

All definitions on the TechTerms website are written to be technically accurate but also easy to understand. If you find this Set definition to be helpful, you can reference it using the citation links above. If you think a term should be updated or added to the TechTerms dictionary, please email TechTerms!

Subscribe to the TechTerms Newsletter to get featured terms and quizzes right in your inbox. You can choose to receive either a daily or weekly email.

Sign up for the free TechTerms Newsletter

How often would you like to receive an email?

You can unsubscribe at any time.
Questions? Please contact us.