Graph
Tuple

📦Tuple

NEW

Also known as: Row, Record

A tuple is an ordered collection of elements, often representing a row in a relational table.

DESCRIPTION

In mathematics, a tuple is a finite ordered list of elements. In databases, a tuple corresponds to a row: a set of attribute values conforming to a table’s schema. In programming, tuples are immutable sequences in many languages, useful for lightweight records. Order and arity matter, distinguishing tuples from sets. Tuples underpin relational algebra and database theory.

ALTERNATIVE DEFINITIONS

Wikipedia

In mathematics, a tuple is a finite ordered list (sequence) of elements.

Formal mathematical characterization as an ordered list.

Source

Python Documentation

A tuple consists of a number of values separated by commas, for instance: t = 12345, 54321, ‘hello!’.

Illustrates tuple syntax and immutability in programming.

Source

Relation Attribute Primary Key Data Schema Relational Model Domain Cartesian Product Ordered Pair

COMPETING TERMS

Set

KNOWLEDGE AREAS

Data Modeling Data Storage & Operations Programming Languages

TARGET AUDIENCE

Data Modeler Data Engineer Software Developer

EXTERNAL SOURCES

TOP QUESTIONS

How is a Tuple used in relational databases?

A tuple represents a row: an ordered set of attribute values adhering to a table schema. It’s fundamental to relational algebra operations.

Category: Example

What is the difference between a Tuple and a Set?

Tuples are ordered and can contain duplicates; sets are unordered and unique. Order and arity define tuples’ identity.

Category: Misunderstanding

Are Tuples immutable?

In many programming languages (e.g., Python), tuples are immutable. However, database tuples can be updated via operations that replace entire rows.

Category: Opinion

What are common mistakes with Tuples in programming?

Confusing parentheses with tuple creation in Python and modifying nested mutable elements, which can affect perceived immutability.

Category: Mistakes

How do Tuples relate to schema evolution?

Changing a table schema alters tuple structure (arity and types). Data migration and versioned contracts help manage evolution safely.

Category: Management

When should I use a Tuple instead of a class or struct?

Use tuples for lightweight, temporary groupings. For domain semantics and maintainability, prefer named records or classes.

Category: Opinion

What is an ordered pair in relation to Tuples?

An ordered pair is a 2-tuple. Generalization to n elements forms n-tuples like triples or quadruples.

Category: Example

How do Tuples appear in APIs?

APIs often return tuples for multiple values. Consider named tuples or data classes for readability.

Category: Best practices

Do Tuples have to be homogeneous?

No. Tuples can mix types, though some strongly typed languages may enforce or type-parameterize element types.

Category: Requirements