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 SQLite, if any of the child key columns (in this case songartist and songalbum) are NULL, then there is no requirement for a corresponding row in the parent table.
I know that cardinality is supposed to be the number of values in a set, or at least it is in math, so I assume if I have ten person records each with a column sex then there are two possibilities male and female so assuming there are some males and some females the cardinality is 2... right?
I searched on google and didn't find much. The closest thing I found was a Microsoft page for Visio 2003 that has a section explaining "About attributes, referential integrity, and cardinality". It says:
The cardinality of a relationship describes how many records in a parent table can be directly related to records in a child table. Cardinality is expressed in terms such as one-to-one, one-to-many, many-to-one, or many-to-many.
That's probably a pretty good description but I still don't understand what SQLite means when it says the parent and child keys must have the same cardinality. If you could give some examples in your answer that would also be helpful. Thanks