Learn

Set theory is used as a foundation for many subfields of mathematics and computer science. Let us explore two areas.

Sets in Data science

A dataset is a collection of numbers or values that relate to a particular subject. A public health authority may maintain a dataset of community health records.

Your local public health authority has decided to support people with cardiac risk by offering healthy lifestyle programs. They wish to make a list of vulnerable community members based on the following criteria: people with hypertension, people aged over 60, and obese people who also have a family history of cardiac issues. Can you help them extract data to make a contact list?

Let H be the set of people with hypertension, A the set of people aged over 60, O the set of obese people, and F the set of people with family history of cardiac issues.

The set of people who are vulnerable = H ∪ A ∪ (O ⋂ F)

Sets in Databases

In databases, records within a table can be treated as objects in a set - i.e. the table becomes a set of records.

SQL (Structured Query Language) is used to communicate with a database. SQL statements are used to perform tasks such as update data on a database, or retrieve data from a database.

Amazon maintains a database of customers and orders. To contact all customers who have placed orders, we need to find the intersection of the customers and orders table. The SQL Inner Join is just the intersection of two sets.

Instructions

Let us look at a daily life example of sets. Can you list the sets you would find in your kitchen?

In a kitchen, the plates are kept separate from bowls and cups. Sets of similar utensils are grouped together. Sets of food-items are kept separate from sets of cleaning-aids.

Take this course for free

By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.
Already have an account?