Can someone help me understand maximum cardinality and min cardinality?

N

Nocturnal

I'm having a hard time understanding this. Can anyone try to explain this
in laymans terms?
 
G

Graham R Seach

Cardinality simply defines the numeric relationship between two objects. In
Object-Oriented (OO) terms, cardinality can be 0, 1, or many, and it applies
to both ends (directions) of the relationship.

What this all means in terms of database design, is that cardinality defines
whether a relationship between the data in two tables is classified as
one-to-one, one-to-many, or many-to-many.

Where two tables participate in a mutual dependence:

* a one-to-one relationship is where a record in one table (Table-A) can
only be related to one record in the other table (Table-B). Going the other
way, any record in Table-B can only be related to one record in Table-A.

* a one-to-many relationship is where a record in Table-A can be related
to any number of records in Table-B, but the reverse is not true. Any record
in Table-B can only be related to one record in Table-A.

* a many-to-many relationship is where a record in Table-A can be
related to many records in Table-B, and (in contrast to the one-to-many
relationship) the reverse IS true. The many-to-many relationship also
permits any record in Table-B to be related to many records in Table-A.

In true OO, you can have a cardinality of zero-to-one or zero-to-many, but
sensibly this is not implemented in databases. What is also not implemented
natively in Access is the many-to-many relationship. To create this
relationship in Access, you must create an intermediate table (Table-C)
between the two tables in question. In this model, the relationship between
Table-A and Table-B is one-to-many, and the relationship between TableB and
Table-C is also one-to-many. The combination of the three tables implements
an effective many-to-many relationship.

To answer your real question about what constitutes minimum and maximum
cardinality; if we take the example of a one-to-many relationship, "one" is
the minimum cardinal, and "many" is the maximum. Similarly, in a zero-to-one
relationship (which as you recall can't be implemented in databases), "zero"
is the minimum, and "one" is the maximum.

Does this make sense?

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
D

Dirk Goldgar

Graham R Seach said:
Cardinality simply defines the numeric relationship between two
objects. In Object-Oriented (OO) terms, cardinality can be 0, 1, or
many, and it applies to both ends (directions) of the relationship.

What this all means in terms of database design, is that cardinality
defines whether a relationship between the data in two tables is
classified as one-to-one, one-to-many, or many-to-many.

Where two tables participate in a mutual dependence:

* a one-to-one relationship is where a record in one table
(Table-A) can only be related to one record in the other table
(Table-B). Going the other way, any record in Table-B can only be
related to one record in Table-A.

* a one-to-many relationship is where a record in Table-A can be
related to any number of records in Table-B, but the reverse is not
true. Any record in Table-B can only be related to one record in
Table-A.

* a many-to-many relationship is where a record in Table-A can be
related to many records in Table-B, and (in contrast to the
one-to-many relationship) the reverse IS true. The many-to-many
relationship also permits any record in Table-B to be related to many
records in Table-A.

In true OO, you can have a cardinality of zero-to-one or
zero-to-many, but sensibly this is not implemented in databases. What
is also not implemented natively in Access is the many-to-many
relationship. To create this relationship in Access, you must create
an intermediate table (Table-C) between the two tables in question.
In this model, the relationship between Table-A and Table-B is
one-to-many, and the relationship between TableB and Table-C is also
one-to-many. The combination of the three tables implements an
effective many-to-many relationship.

To answer your real question about what constitutes minimum and
maximum cardinality; if we take the example of a one-to-many
relationship, "one" is the minimum cardinal, and "many" is the
maximum. Similarly, in a zero-to-one relationship (which as you
recall can't be implemented in databases), "zero" is the minimum, and
"one" is the maximum.

Graham, wouldn't "maximum cardinality" reflect the concept of those
relationships in which there is a maximum number of entities on the many
side of a relationship? So that, for instance, in a personnel database
you have a business rule that a manager supervises no more than 5
employees? Meanwhile, you have a minimum cardinality of 0 on the other
side, since the CEO has no supervisor.
 
G

Graham R Seach

Dirk,

Yes, you can define cardinality that way, because object relationships can
be declared as mandatory or optional, but it's not mormally done that way.
That sort of relationship is usually declared in use case scenarios, and in
specs, because it can't be enforced architecturally. Applying a strict data
modelling definition, cardinality refers to the number of associations that
naturally (architecturally) occur between objects.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------
 
R

Ralph

Graham R Seach said:
Dirk,

Yes, you can define cardinality that way, because object relationships can
be declared as mandatory or optional, but it's not mormally done that way.
That sort of relationship is usually declared in use case scenarios, and in
specs, because it can't be enforced architecturally. Applying a strict data
modelling definition, cardinality refers to the number of associations that
naturally (architecturally) occur between objects.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

It really isn't a matter of "you can define cardinality that way" - that is
the definition. Especially when it comes to 'Minimum' and 'Maximum', as it
can be "enforced architecturally". (Just not in a Relational Model)

What is missing is the delimination between Object Oriented modeling and
Relational Data modeling. The two are easily confused because of the common
use of similar jargon and the fact that during design both camps pull
modeling techniques from the other. Cardinality being a good example.

As you noted 'zero to many' has no 'real-world' expression to the data
modeler, but has a very definite impact on an OO model and on its subsequent
architecture and implementation.

As this is a 'database' newsgroup, one would naturally assume the OP was
requesting information on "Data Modeling", but whenever defining modeling
terms it always important to make a clear distinction as to the specific
model we are talking about.

-ralph
 
G

Graham R Seach

Ralph,

Yes, although I touched on OO modelling in my original post, you can see
that I was referring to the relational model as it specifically pertains to
Access. And it's for that reason that I mentioned the inability (in Access
tables/relationships - architecturally) to define the type of constraints
that Dirk raised.

Perhaps I should have clarified "...but it's not mormally done that way", to
specify "in Access".

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------
 
R

Ralph

Graham R Seach said:
Ralph,

Yes, although I touched on OO modelling in my original post, you can see
that I was referring to the relational model as it specifically pertains to
Access. And it's for that reason that I mentioned the inability (in Access
tables/relationships - architecturally) to define the type of constraints
that Dirk raised.

Perhaps I should have clarified "...but it's not mormally done that way", to
specify "in Access".

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Yes you did. I read too quickly and got hung up on the "not normally" reply
to Dirk.

My over-looked, jumped-too quick bad. <g>

-ralph
 
T

Tony Toews

Fred Boer said:
Well, I hope it helped the OP, 'cause it gave me a case of the screaming,
full-bore, math-phobic heebie jeebies! :-O

I'll be ok, though... I can get through this... ok, Fred, keep calm... don't
think about numbers... keep thinking about Catholics in red robes and little
red birds...

<chuckle> I was thinking the same. I ain't none too good with
theory.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
 
Top