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

274 questions
2
votes
1 answer

SQL - Foreign key constraints and cardinality

Can someone explain foreign key constraints and cardinality? I am reading the SQLite manual and I am at the section on advanced foreign key constraint features. In its explanation it says: Parent and child keys must have the same cardinality. In…
user2672807
  • 1
  • 2
  • 7
  • 20
2
votes
1 answer

still confused about cardinality

after watching some tutorials, I feel like I am still confused about cardinality when it comes to one to many and many to many relationship. I am trying to practice a little example here, I know my design is wrong when it comes to cardinality, what…
Ris
  • 1,892
  • 9
  • 26
  • 43
2
votes
2 answers

Why is possible Alloy negative cardinality

I am describing some models in Alloy language. In order to describe a finite state machine I provided this few lines of code: sig FSA_state { transitions: some FSA_state, initial: lone InitialState } sig InitialState {} fact i { all f:…
2
votes
2 answers

Bad cardinality for tables with composite primary key

When joining two tables via a composite (two column) primary key, I get bad cardinality estimates in the query plan. Example: CREATE TABLE t1 AS SELECT x, x*2 AS x2 FROM generate_series(0, 1000) AS x; ALTER TABLE t1 ADD PRIMARY KEY(x, x2); ANALYZE…
Karl Bartel
  • 3,244
  • 1
  • 29
  • 28
2
votes
0 answers

index cardinality problems after recreating huge myisam table

Lately i have been tasked to delete and reinsert approximately 15 million rows on a myisam table that has about 150 million rows doing so while the table/db still remains available for inserts/reads. In order to do so i have started a process that…
2
votes
1 answer

What to do with a 1 --> 0..1 relationship?

We have a Claim entity which might be proved by either a EmailVerification , put MetaCode in the relevant website or uploading CertificateFile. Now the problem is the claimer may choose to prove their claim by using any combination of the methods…
Ashkan Kh. Nazary
  • 21,844
  • 13
  • 44
  • 68
2
votes
4 answers

How do I dynamically assign the size to an array in C++?

So right now I have a class, called Set, in C++. In it, I have an integer called mCardinality, and an integer array called mElements. I want to be able to accept an integer in the constructor for mCardinality, then use this to assign a size to my…
Taylor Matyasz
  • 127
  • 1
  • 1
  • 5
1
vote
1 answer

Cognos Query Join Relationship Cardinality Guidance Needed

I have two queries 'Stock' and 'Dues' that I combined using a query join to create Stock_&_Dues as I want the data from both queries to populate in the same report page. For some reason I'm getting all the data from 'Stock' and 'Dues' when both…
aidan330
  • 53
  • 5
1
vote
2 answers

0-to-many and 1- to-many relationship in PostgreSQL code

From a PostgreSQL article on foreign keys constraints at https://www.postgresql.org/docs/current/ddl-constraints.html: Say you have the product table : CREATE TABLE products ( product_no integer PRIMARY KEY, name text, price…
moth
  • 1,833
  • 12
  • 29
1
vote
2 answers

Elasticsearch query with time range and cardinality

I need help with ES query for both Time Range and Cardinality. For now, my query for Time Range is as follow: query={ "query": { "bool": { "must": [ { "query_string": { "query":…
TD JSmith
  • 11
  • 2
1
vote
1 answer

'max' and 'exactly' cardinality restrictions in the context of the OWA

In first place i have to apologize for my very, very poor english. I've been studying the representation of knowledge in the context of design of experts systems trough ontologies. In particular, i've been using protégé as an OWL ontology…
1
vote
1 answer

Does a nullable foreign key always mean optional in ERD cardinality?

Suppose you have a ticket table and a status ticket. Below are their definitions: CREATE TABLE `priorities`( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `name` INT NOT NULL, constraint `priorities_id_primary` Primary key (`id`) ); CREATE…
Alireza Noori
  • 14,961
  • 30
  • 95
  • 179
1
vote
1 answer

Composite and Terms Aggregations on a field with a high cardinality

I am facing a huge performance problem with ES which results in more than 2 min response. I have an index that has more than 25M files and composes of the next 4 fields (among others): ... "group_write": { "type": "text", …
1
vote
1 answer

Client-Side Pre-Computed Hashes for ElasticSearch Cardinality Aggregation

In the ElasticSearch documentation for the Cardinality Aggregation under the heading "Pre-computed hashes" I see the following: On string fields that have a high cardinality, it might be faster to store the hash of your field values in your index…
knpwrs
  • 15,691
  • 12
  • 62
  • 103
1
vote
1 answer

XSD describing arbitrary number of same child elements - xs:all / xs:sequence / xs:choice and cardinalities

I am trying to describe something like the following XML in XSD: There are some additional constraints: there is only one componentDefinition block the…
1um0
  • 23
  • 5