Cardinality
Cardinality is the number of elements in a set or collection, or the number of distinct values represented by a variable or dataset.
Grokking Relational Database Design
Cardinality is the number of instances of a target entity that can be associated with one instance of a source entity in a directional relationship.
- How it is used
- Guides E-R diagram design by turning relationship requirements into cardinalities and foreign-key decisions.
- How deep it goes
- Explains directional minimum and maximum limits, notation, three relationship types, and implementation consequences including insertion constraints.
- Examples
- Uses user-account, department-manager, and user-review relationships to derive cardinalities and table links.
- What you can do after
- Apply it to classify entity relationships, draw Crow’s Foot limits, and place foreign keys or junction tables.
Read how Grokking Relational Database Design explains cardinality →
Graph Algorithms for Data Science
Query cardinality is the number of rows or records in the input or intermediate result stream available to a query operation.
- How it is used
- Guides Cypher aggregation and sequential pattern matching so counts remain meaningful and queries avoid unnecessary work.
- How deep it goes
- Defines row-stream cardinality and demonstrates distinct counts, counting subqueries, and intermediate reduction with Cypher queries.
- Examples
- Uses Twitter mentions, independent User and Tweet matches, and mention-distribution queries to expose repeated and multiplied rows.
- What you can do after
- Diagnose/debug with Cypher by identifying row multiplication, selecting distinct counts, and reducing intermediate streams with aggregation.
Read how Graph Algorithms for Data Science explains cardinality →
Latency
Cardinality is the number of distinct values in a dataset or column.
- How it is used
- Guides partition-key choice for horizontal partitioning by indicating how many distinct values are available to distribute rows.
- How deep it goes
- Defines high and low cardinality with column examples and explains their effect on partition balance, without specifying a measurement procedure.
- Examples
- Contrasts distinct user IDs with the limited values of an order-status column.
- What you can do after
- Evaluate/understand it when comparing partition keys and distinguishing uneven data distribution from hot-partition workloads.
Logs and Telemetry
Cardinality is the number of distinct label-value combinations or dimensions represented in a telemetry data set.
- How it is used
- Guides Prometheus label design and telemetry sizing for querying, diagnosis, correlation, and exporter operation.
- How deep it goes
- Defines dimensions and demonstrates their output, while warning about operational effects without exploring cardinality management in depth.
- Examples
- Uses CPU, disk, server, exporter, service-group, and greeting labels to contrast dimensioned metrics with aggregate totals.
- What you can do after
- Evaluate metric labels by comparing diagnostic value with the additional values collected and calculated for each dimension.
Ensemble Methods for Machine Learning
Cardinality is the number of unique categories or values represented by a categorical feature.
- How it is used
- Guides categorical encoding decisions by distinguishing features with few categories from high-cardinality string features.
- How deep it goes
- Defines unique-category counting and connects it to encoding tradeoffs, but stops short of formal analysis.
- Examples
- Uses employee job titles, category-count diagnostics, spelling variants, and alternate titles as concrete examples.
- What you can do after
- Apply it via category-count diagnostics and choose encoders such as SimilarityEncoder, MinHashEncoder, or GapEncoder.
Read how Ensemble Methods for Machine Learning explains cardinality →
PostgreSQL Mistakes and How to Avoid Them
Cardinality is the number or diversity of distinct values in a set or key column.
- How it is used
- Guides selection of partition keys that distribute PostgreSQL rows evenly across partitions.
- How deep it goes
- Explains distribution consequences and stops short of a general mathematical treatment.
- Examples
- Uses monthly timestamp partitions and contrasts full-table scanning with a plan scanning one partition.
- What you can do after
- Evaluate partition keys for even distribution and anticipate excessive scans or poor execution plans.
Read how PostgreSQL Mistakes and How to Avoid Them explains cardinality →
Outlier Detection in Python
The number of distinct values or categories represented by a variable or column.
- How it is used
- Uses cardinality to distinguish categorical from string columns and to calibrate categorical outlier detection.
- How deep it goes
- Explains cardinality through column types, count distributions, normalized rarity, and sparse combinations, but does not develop a formal estimator.
- Examples
- Uses staff expenses, SpeedDating categorical distributions, and multi-column combination counts to illustrate cardinality.
- What you can do after
- Evaluate whether categorical rarity or multi-column sparsity supports an outlier flag without treating uncommon values as automatically anomalous.
Cloud Observability in Action
Metric cardinality is the number of distinct values or combinations represented by a metric’s dimensions or labels.
- How it is used
- Frames metric-label design as a practical driver of observability storage and query costs.
- How deep it goes
- Defines cardinality and demonstrates its cost implications, while deferring detailed cardinality-explosion treatment.
- Examples
- Contrasts HTTP status-code labels with user-ID labels in metric series.
- What you can do after
- Evaluate metric labels for potential storage and query-cost increases.
Read how Cloud Observability in Action explains cardinality →
Related concepts
- data aggregationconfigured by · Data aggregation is the combination of multiple values, records, observations, or results into a consolidated or summarized output.
- edgemeasures · An edge is a graph connection between two vertices that represents a relationship and may be directed, labeled, or weighted.
- maximum cardinalityhas part · Maximum cardinality is the largest number of target-entity instances with which one source-entity instance can be associated.
- minimum cardinalityhas part · Minimum cardinality is the smallest number of related entity instances required or permitted for an entity instance in a relationship.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.







