Chapter 1.1 Sets, Relations & Cardinality in Archaeology

Chapter 1.1 Sets, Relations & Cardinality in Archaeology

Objective: Understand sets, relations, and cardinality — the foundational structures of data thinking — and how they relate to archaeological contexts.

Welcome to the excavation site of Tell Logika, a fictional but data-rich archaeological dig we will return to throughout this book. Each chapter will involve discoveries, trench records, artifacts, elevations, or material composition. In this chapter, you’ll learn the abstract concepts that help organize this kind of data in the digital world.

Visual Reference: Here’s a sketch of our fictional site layout at Tell Logika with labeled trenches and zones.

1.1.1 What is a Set?

A set is a collection of distinct elements, typically written with curly braces { }.

Examples:

  • {"TL01", "TL02", "TL03"} – trench IDs from Tell Logika
  • {"ceramic", "metal", "stone"} – types of materials

In archaeology, sets can represent a group of trench names, artifact types, or stratigraphic units. They help in categorizing and comparing grouped data.

1.1.2 Set Operations

Key operations:

  • Union (A ∪ B): All elements from both sets
  • Intersection (A ∩ B): Elements in both sets
  • Difference (A − B): Elements in A but not in B

If trench A has {"ceramic", "metal"} and trench B has {"ceramic", "stone"}, then:

  • A ∩ B = {"ceramic"}
  • A ∪ B = {"ceramic", "metal", "stone"}
  • A − B = {"metal"}

1.1.3 What is a Relation?

A relation connects elements between two sets — like linking trench IDs to elevation data or artifact types to trench IDs.

Example: ("TL01", 150) — Trench TL01 is at 150m elevation.

Relations are the basis of structured data and tabular formats such as spreadsheets, CSV files, and databases.

1.1.4 Functions as Special Relations

A function is a special type of relation where every element in the first set (domain) maps to exactly one element in the second set (range).

Example: Trench → Total Artifacts, such as ("TL01" → 120)

Functions are used to build clean datasets where every trench has only one elevation or one total artifact count.

1.1.5 Cardinality

Cardinality refers to the number of elements in a set.

Notation: |A|

Example: If A = {"ceramic", "metal", "stone"}, then |A| = 3

This concept is useful for describing diversity in artifact assemblages or measuring the number of unique trench IDs.

1.1.6 Real-World Example: Tell Logika Artifact Data

Sets:

  • Trenches = {"TL01", "TL02", "TL03"}
  • Materials = {"ceramic", "metal", "stone"}

Relations: (Trench, Material) → Count

An excavation spreadsheet might represent this as rows linking trench IDs to artifact types and quantities.

1.1.7 Why It Matters

Why learn these abstract ideas?

  • They’re the foundation of structured archaeological datasets
  • They enable filtering and comparison in Python and GIS
  • They help define clean, searchable field records and digital tables

1.1.8 Up Next

Next, you’ll see how these concepts — sets, relations, cardinality — are represented in Python using sets, tuples, lists, and dictionaries.

This Week’s Reading:

1.1.9 Quick Review

  • ✅ A Set = a group of unique values
  • ✅ A Relation = links elements between sets
  • ✅ A Function = each input has one output
  • Cardinality = the number of items in a set (|A|)

📘 Activity: Mapping Relations at Tell Logika

Scenario: At the fictional excavation site Tell Logika, you are recording relationships between trenches and the primary artifact types found in each trench. You will represent these relationships manually (on paper or in Excel) before coding.

Instructions:

  1. Sketch out a set of 3 trench IDs: TL01, TL02, TL03
  2. Sketch a set of artifact types: ceramic, metal, stone
  3. Link each trench to the types of artifacts found — this is your relation
  4. For each trench, determine how many distinct artifact types it has — that’s the cardinality, written as |Set|
  5. Try using Excel or a table in a notebook to list these as pairs: (Trench, Artifact)

Example Table:

TL01 – ceramic, metal
TL02 – ceramic
TL03 – stone, ceramic, metal

Reflect:

  • Which trench had the highest cardinality?
  • Are there any materials found in all trenches (intersection)?
  • Which materials are unique to a trench (difference)?

Next step: In the next section, we’ll express this same structure using Python code.

🔗 GitHub Resources: All code and examples for this book