Questions tagged [cardinality]

In data modeling, the cardinality of one data table with respect to another data table is a critical aspect of database design. Relationships between data tables define cardinality when explaining how each table links to another. In the relational model, tables can be related as any of: many-to-many, many-to-one (rev. one-to-many), or one-to-one. This is said to be the cardinality of a given table in relation to another.

In data modeling, the cardinality of one data table with respect to another data table is a critical aspect of database design. Relationships between data tables define cardinality when explaining how each table links to another.

In the relational model, tables can be related as any of: many-to-many, many-to-one (rev. one-to-many), or one-to-one. This is said to be the cardinality of a given table in relation to another.

Wikipedia article

240 questions
90
votes
14 answers

Is it possible to determine the number of elements of a c++ enum class?

Is it possible to determine the cardinality of a c++ enum class: enum class Example { A, B, C, D, E }; I tried to use sizeof, however, it returns the size of an enum element. sizeof(Example); // Returns 4 (on my architecture) Is there a standard…
bquenin
  • 1,135
  • 1
  • 10
  • 12
88
votes
6 answers

What is cardinality in Databases?

I have been searching all over the internet but I couldn't seem to find an answer that I can understand. So kindly, if somebody could explain to me with the help of examples what is cardinality in databases? Thank you.
Some Body
  • 1,643
  • 3
  • 18
  • 16
47
votes
5 answers

Does it make sense to use an index that will have a low cardinality?

I'm mainly an Actionscript developer and by no means an expert in SQL, but from time to time I have to develop simple server side stuff. So, I thought I'd ask more experienced people about the question in the title. My understanding is that you…
Juan Pablo Califano
  • 11,936
  • 5
  • 27
  • 41
23
votes
3 answers

How to *really* write UML cardinalities?

I would like to know once and for all how to write UML cardinalities, since I very often had to debate about them (so proofs and sources are very welcome :) If I want to explain that a Mother can have several Children but a Child has one and only…
sp00m
  • 44,266
  • 23
  • 127
  • 230
22
votes
1 answer

MySQL index cardinality - performance vs storage efficiency

Say you have a MySQL 5.0 MyISAM table with 100 million rows, with one index (other than primary key) on two integer columns. From my admittedly poor understanding of B-tree structure, I believe that a lower cardinality means the storage efficiency…
Sean
  • 771
  • 1
  • 4
  • 14
20
votes
4 answers

Why is using dplyr pipe (%>%) slower than an equivalent non-pipe expression, for high-cardinality group-by?

I thought that generally speaking using %>% wouldn't have a noticeable effect on speed. But in this case it runs 4x slower. library(dplyr) library(microbenchmark) set.seed(0) dummy_data <- dplyr::data_frame( id=floor(runif(10000, 1, 10000)) …
logworthy
  • 1,108
  • 1
  • 10
  • 22
18
votes
4 answers

What is the definition of cardinality in SQL

My school book Database Systems defines cardinality as follows: The cardinality of a relation is the number of tuples it contains. By contrast, the number of tuples is called the cardinality of the relation and this changes as tuples are added or…
Tobias Schultz
  • 183
  • 1
  • 1
  • 4
16
votes
2 answers

How do you count cardinality of very large datasets efficiently in Python?

I have been playing at work with some very very large sets of data, typically several billions of elements, that are all maintained in a memcached cloud and periodically dumped into files, and for one of my tasks I'm trying to count the cardinality…
Charles Menguy
  • 38,416
  • 17
  • 91
  • 113
12
votes
2 answers

Is NULL cardinality in an index a problem - MySQL 5.x

I'm having performance problems on the live version of a system which I can't reproduce locally. In comparing a few EXPLAIN results on my local copies of the database with the live one, I note that multi-field indexes aren't used in some places on…
taliesinnuin
  • 159
  • 1
  • 5
10
votes
4 answers

PostgreSQL: How to implement minimum cardinality?

As answered in this question: Cardinality in PostgreSQL, cardinality is enfforced using constraints. Cardinality rules define the allowable counts of the relationships – one-to-many, many-to-many, etc. Many-to-many is achieved using join-tables and…
user1144616
  • 1,051
  • 2
  • 12
  • 16
10
votes
2 answers

Why does the cardinality of an index in MySQL remain unchanged when I add a new index?

I have added a FULLTEXT index to one of my MySQL database tables as follows: ALTER TABLE members ADD FULLTEXT(about,fname,lname,job_title); The problem is that using phpmyadmin I can see the cardinality of my new index is only 1. Does this mean the…
Tom
  • 13,085
  • 12
  • 61
  • 77
10
votes
3 answers

is there an ordinal to cardinal function in ruby or rails?

I'm trying to find a better way in expressing my cucumbers so I am looking for an ordinal to cardinal function that converts this: When I fill up the first passenger field Then I should see the passenger list update with the first passenger…
corroded
  • 20,408
  • 18
  • 80
  • 130
9
votes
1 answer

high and low cardinality in Cassandra

I keep coming across these terms: high cardinality and low cardinality in Cassandra. I don't understand what exactly they mean. what effects they have on queries and what is preferred. Please explain with example since that will be be easy to…
eagertoLearn
  • 8,372
  • 22
  • 66
  • 108
9
votes
1 answer

Difference between cardinality "*", and "0..*" - UML

What's the difference between the operator * and the operator 0..* in UML (unified modeling language)? I saw this two cardinality operators, but I don't now which one I must to use.
guisantogui
  • 3,608
  • 6
  • 45
  • 83
9
votes
1 answer

How do I add multiplicity values in StarUML

I am studying Database Development and I am at the stage where I have to create my own ER Models. Everything is fine so far with StarUML however the course notes don't mention how to add muliplicity options between entity types (the cardinality and…
Peter Stuart
  • 2,162
  • 6
  • 38
  • 69
1
2 3
15 16