Search code examples
axaptax++dynamics-365-operations

Table Cardinality in Microsoft Dynamics 365 F&O


When creating a table in Microsoft Dynamics 365 F&O there are two fields that confuses me and I can't find the right documentation to fullfill them. They are "Cardinality" and "Related table cardinality".

I've tried to search throught this link but couldn't find anything about cardinality.

For what I can supose, they can be used as it follows:

  • Many to one (not required):
  • Cardinality: ZeroMore
  • Related table cardinality: ZeroOne
  • Many to one (required):
  • Cardinality: OneMore
  • Related table cardinality: ExaclyOne
  • One to one (not required):
  • Cardinality: ExaclyOne
  • Related table cardinality: ZeroOne

I'm supposing that "ZeroOne" would be "I'm zero and you are one" or "OneMore" would be "I'm one and you are more" line of thought.

But "ZeroMore" can't seem to fit in the usual database relationship since there are only two related table cardinality options: "ZeroOne" and "ExaclyOne".

Can someone find a better explanation for this or send me a propper documentation link?

Thanks in advance.


Solution

  • It can be confusing and the easiest way to figure it out might be just looking at tables and relations that you already understand the relationship.

    Table cardinality refers to the relationship between two tables in a database, which specifies how many records in one table can be associated with one or more records in another table. In other words, it defines how many instances of one entity can be related to how many instances of another entity.

    • ZeroOne (0:1): In this relationship, each record in one table can be associated with at most one record in another table, and vice versa. This means that there can be zero or one relationship between the two tables. For example, a person can have at most one passport, and each passport is associated with at most one person. They may not have a passport though too.

    • ExactlyOne (1:1): In this relationship, each record in one table is associated with exactly one record in another table, and vice versa. This means that there is a one-to-one relationship between the two tables. For example, a Sales Order can only have exactly 1 customer (1:1), but inversely...see next example (0:n). Or a PurchLine can have ExactlyOne record of PurchTable.

    • ZeroMore (0:n): In this relationship, each record in one table can be associated with zero or more records in another table, but each record in the second table is associated with at most one record in the first table. This means that there can be zero or more relationships between the two tables. For example, a customer can have zero or more orders, but each order is associated with at most one customer.

    • OneMore (1:n): In this relationship it means that each record in one table can be associated with one or more records in another table, but each record in the second table can be associated with at most one record in the first table. This is also known as a one-to-many relationship. I don't have a great example off the top of my head for this because AFAIK this relation is only used in very specific cases.

    A good example of the cardinality is the PurchLine relation to PurchTable (\Data Dictionary\Tables\PurchLine\Relations\PurchTable).

    The cardinality of the PurchTable relation ON the PurchLine table is ZeroMore and it refers to the fact that you can have zero or more PurchLine records for a given PurchTable record, because you may create a PO without any lines.

    The RelatedTableCardinality refers to PurchTable, where there can be ExactlyOne PO header. You cannot have a PO line that exists across multiple PO's.